本文整理了Java中io.fabric8.groups.Group.isMaster()
方法的一些代码示例,展示了Group.isMaster()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Group.isMaster()
方法的具体详情如下:
包路径:io.fabric8.groups.Group
类名称:Group
方法名:isMaster
[英]Check if we are the master.
[中]看看我们是不是主人。
代码示例来源:origin: io.fabric8/fabric-groups
@Override
public boolean isMaster() {
Group<T> group = this.group;
if (group != null) {
return group.isMaster();
} else {
return false;
}
}
代码示例来源:origin: jboss-fuse/fabric8
@Override
public boolean isMaster() {
Group<T> group = this.group;
if (group != null) {
return group.isMaster();
} else {
return false;
}
}
代码示例来源:origin: io.fabric8.insight/insight-metrics
@Override
public void groupEvent(Group<QueryNodeState> group, GroupEvent event) {
try {
state.lock.update(new QueryNodeState(queryName, containerName,
state.lock.isMaster() ? new String[]{"stat"} : null));
} catch (IllegalStateException e) {
// not joined ? ignore
}
}
});
代码示例来源:origin: jboss-fuse/fabric8
@Override
public void groupEvent(Group<QueryNodeState> group, GroupEvent event) {
try {
state.lock.update(new QueryNodeState(queryName, containerName,
state.lock.isMaster() ? new String[]{"stat"} : null));
} catch (IllegalStateException e) {
// not joined ? ignore
}
}
});
代码示例来源:origin: fabric8io/jube
protected void onGroupEvent(Group<ReplicatorNode> group, GroupListener.GroupEvent event) {
switch (event) {
case CONNECTED:
case CHANGED:
if (isValid()) {
try {
if (group.isMaster()) {
enableMaster();
} else {
disableMaster();
}
} catch (IllegalStateException e) {
// Ignore
}
} else {
LOG.info("Not valid with master: " + group.isMaster()
+ " curator: " + curator);
}
break;
case DISCONNECTED:
default:
}
}
代码示例来源:origin: io.fabric8/fabric-camel
@Override
public void groupEvent(Group group, GroupEvent event) {
switch (event) {
case CONNECTED:
break;
case CHANGED:
if (singleton.isConnected()) {
if (singleton.isMaster()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Master/Standby endpoint is Master for: " + endpoint + " in " + endpoint.getCamelContext());
}
onLockOwned();
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Master/Standby endpoint is Standby for: " + endpoint + " in " + endpoint.getCamelContext());
}
}
}
break;
case DISCONNECTED:
try {
stopConsumer();
} catch (Exception e) {
LOG.error("Failed to stop master consumer for: " + endpoint + ". Reason: " + e, e);
}
break;
}
}
代码示例来源:origin: io.fabric8/fabric-openshift
@Override
public void groupEvent(Group<ControllerNode> group, GroupEvent event) {
if (isValid()) {
if (group.isMaster()) {
LOGGER.info("OpenShiftDeployAgent is the master");
} else {
LOGGER.warn("No fabricService yet!");
if (group.isMaster()) {
ControllerNode state = createState();
group.update(state);
if (group.isMaster()) {
dataStore.trackConfiguration(runnable);
onConfigurationChanged();
代码示例来源:origin: jboss-fuse/fabric8
@Override
public void groupEvent(Group group, GroupEvent event) {
switch (event) {
case CONNECTED:
break;
case CHANGED:
if (singleton.isConnected()) {
if (singleton.isMaster()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Master/Standby endpoint is Master for: " + endpoint + " in " + endpoint.getCamelContext());
}
onLockOwned();
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Master/Standby endpoint is Standby for: " + endpoint + " in " + endpoint.getCamelContext());
}
}
}
break;
case DISCONNECTED:
try {
stopConsumer();
} catch (Exception e) {
LOG.error("Failed to stop master consumer for: " + endpoint + ". Reason: " + e, e);
}
break;
}
}
代码示例来源:origin: jboss-fuse/fabric8
private void updateMasterUrl(Group<GitNode> group) {
try {
if (group.isMaster()) {
LOGGER.debug("Git repo is the master");
if (!isMaster.getAndSet(true)) {
registerServlet(dataPath, realm, roles);
}
} else {
LOGGER.debug("Git repo is not the master");
if (isMaster.getAndSet(false)) {
unregisterServlet();
}
}
GitNode state = createState();
group.update(state);
String url = state.getUrl();
gitRemoteUrl.set(ZooKeeperUtils.getSubstitutedData(curator.get(), url));
} catch (Exception e) {
LOGGER.debug("Failed to update master git server url.", e);
}
}
代码示例来源:origin: io.fabric8/fabric-git-server
private void updateMasterUrl(Group<GitNode> group) {
try {
if (group.isMaster()) {
LOGGER.debug("Git repo is the master");
if (!isMaster.getAndSet(true)) {
registerServlet(dataPath, realm, role);
}
} else {
LOGGER.debug("Git repo is not the master");
if (isMaster.getAndSet(false)) {
unregisterServlet();
}
}
GitNode state = createState();
group.update(state);
String url = state.getUrl();
gitRemoteUrl.set(ZooKeeperUtils.getSubstitutedData(curator.get(), url));
} catch (Exception e) {
// Ignore
}
}
代码示例来源:origin: io.fabric8/fabric-camel
@Override
public void groupEvent(Group<CamelNodeState> group, GroupEvent event) {
if (group.isMaster()) {
if (started.compareAndSet(false, true)) {
info("Camel context %s is now the master, starting the context.", groupName);
try {
camelContext.start();
// Update the state of the master since he is now running.
group.update(createState());
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
if (started.compareAndSet(true, false)) {
info("Camel context %s is now a slave, stopping the context.", groupName);
try {
camelContext.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
代码示例来源:origin: jboss-fuse/fabric8
@Override
public void groupEvent(Group<CamelNodeState> group, GroupEvent event) {
if (group.isMaster()) {
if (started.compareAndSet(false, true)) {
info("Camel context %s is now the master, starting the context.", groupName);
try {
camelContext.start();
// Update the state of the master since he is now running.
group.update(createState());
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
if (started.compareAndSet(true, false)) {
info("Camel context %s is now a slave, stopping the context.", groupName);
try {
camelContext.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
代码示例来源:origin: io.fabric8.insight/insight-elasticsearch
@Override
public void publish(ClusterState clusterState, AckListener ackListener) {
logger.debug("Publishing cluster state");
if (!singleton.isMaster()) {
throw new ElasticsearchIllegalStateException("Shouldn't publish state when not master");
}
latestDiscoNodes = clusterState.nodes();
publishClusterState.publish(clusterState, ackListener);
logger.debug("Cluster state published");
}
代码示例来源:origin: io.fabric8.insight/insight-elasticsearch-discovery
@Override
public void publish(ClusterState clusterState, AckListener ackListener) {
logger.debug("Publishing cluster state");
if (!singleton.isMaster()) {
throw new ElasticsearchIllegalStateException("Shouldn't publish state when not master");
}
latestDiscoNodes = clusterState.nodes();
publishClusterState.publish(clusterState, ackListener);
logger.debug("Cluster state published");
}
代码示例来源:origin: jboss-fuse/fabric8
@Override
public void publish(ClusterState clusterState, AckListener ackListener) {
logger.debug("Publishing cluster state");
if (!singleton.isMaster()) {
throw new ElasticsearchIllegalStateException("Shouldn't publish state when not master");
}
latestDiscoNodes = clusterState.nodes();
publishClusterState.publish(clusterState, ackListener);
logger.debug("Cluster state published");
}
代码示例来源:origin: io.fabric8.insight/insight-metrics
if (query.lock != null && !query.lock.isMaster()) {
return;
代码示例来源:origin: io.fabric8/fabric-git-server
private GitNode createState() {
RuntimeProperties sysprops = runtimeProperties.get();
String runtimeIdentity = sysprops.getRuntimeIdentity();
GitNode state = new GitNode("fabric-repo", runtimeIdentity);
if (group != null && group.isMaster()) {
String externalGitUrl = readExternalGitUrl();
if( externalGitUrl!= null){
state.setUrl( externalGitUrl);
} else {
String fabricRepoUrl = "${zk:" + runtimeIdentity + "/http}/git/fabric/";
state.setUrl(fabricRepoUrl);
}
}
return state;
}
代码示例来源:origin: jboss-fuse/fabric8
private GitNode createState() {
RuntimeProperties sysprops = runtimeProperties.get();
String runtimeIdentity = sysprops.getRuntimeIdentity();
GitNode state = new GitNode("fabric-repo", runtimeIdentity);
if (group != null && group.isMaster()) {
String externalGitUrl = readExternalGitUrl();
if (externalGitUrl != null) {
state.setUrl(externalGitUrl);
} else {
String fabricRepoUrl = "${zk:" + runtimeIdentity + "/http}/git/fabric/";
state.setUrl(fabricRepoUrl);
}
}
return state;
}
代码示例来源:origin: jboss-fuse/fabric8
AutoScalerNode state = createState();
try {
if (group.isMaster()) {
enableMasterZkCache(curator.get());
LOGGER.info("AutoScaleController is the master");
LOGGER.info("Not valid with master: " + group.isMaster()
+ " fabric: " + fabricService.get()
+ " curator: " + curator.get());
代码示例来源:origin: io.fabric8/fabric-partition
@Override
public void groupEvent(Group<WorkerNode> group, GroupEvent event) {
switch (event) {
case CONNECTED:
case CHANGED:
WorkerNode state = createNode();
if (group.isMaster()) {
repository.start();
state.setServices(new String[] {context.getId()});
group.update(state);
partitionUpdated();
} else {
group.update(state);
repository.stop();
}
break;
case DISCONNECTED:
repository.stop();
}
}
内容来源于网络,如有侵权,请联系作者删除!