本文整理汇总了Java中org.apache.curator.framework.state.ConnectionState.LOST属性的典型用法代码示例。如果您正苦于以下问题:Java ConnectionState.LOST属性的具体用法?Java ConnectionState.LOST怎么用?Java ConnectionState.LOST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.curator.framework.state.ConnectionState
的用法示例。
在下文中一共展示了ConnectionState.LOST属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stateChanged
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
if (newState == ConnectionState.CONNECTED) {
isConnected.set(true);
if (!isFirstConnection.get()) {
for (ConnectionStateListener listener : listenerStateProxy.getListeners()) {
listener.stateChanged(client, ConnectionState.RECONNECTED);
}
}
return;
}
if (newState == ConnectionState.LOST) {
isConnected.set(false);
isFirstConnection.set(false);
retryConnection();
}
}
示例2: stateChanged
@Override
public void stateChanged(final CuratorFramework client, final ConnectionState newState) {
JobScheduleController jobScheduleController = JobRegistry.getInstance().getJobScheduleController(jobName);
if (ConnectionState.LOST == newState) {
jobScheduleController.pauseJob();
} else if (ConnectionState.RECONNECTED == newState) {
if (!leaderElectionService.hasLeader()) {
leaderElectionService.leaderElection();
}
serverService.persistServerOnline();
executionService.clearRunningInfo(shardingService.getLocalHostShardingItems());
if (!serverService.isJobPausedManually()) {
jobScheduleController.resumeJob();
}
}
}
示例3: stateChanged
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
mIsLeader.set(false);
if ((newState == ConnectionState.LOST) || (newState == ConnectionState.SUSPENDED)) {
if (mCurrentMasterThread != null) {
mCurrentMasterThread.interrupt();
}
} else {
try {
LOG.info("The current leader is " + LEADER_SELECTOR.getLeader().getId());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}
示例4: stateChanged
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
if (newState == ConnectionState.SUSPENDED || newState == ConnectionState.LOST) {
this.isLeader = false;
leaderExecutor.shutdownNow();
throw new CancelLeadershipException();
}
}
示例5: stateChanged
@Override
public void stateChanged(CuratorFramework framework, ConnectionState newState) {
if (newState == ConnectionState.SUSPENDED || newState == ConnectionState.LOST) {
this.isLeader = false;
leaderExecutor.shutdownNow();
throw new CancelLeadershipException();
}
}
示例6: stateChanged
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
if (newState == ConnectionState.LOST) {
LOG.error("Aborting due to new connection state received from ZooKeeper: {}", newState);
abort(AbortReason.LOST_ZK_CONNECTION, Optional.<Throwable>absent());
}
}
示例7: KafkaConsumerCache
/**
* Creates a KafkaConsumerCache object. Before it is used, you must call
* startCache()
*
* @param apiId
* @param s
* @param metrics
*/
public KafkaConsumerCache(String apiId, MetricsSet metrics) {
if (apiId == null) {
throw new IllegalArgumentException("API Node ID must be specified.");
}
fApiId = apiId;
// fSettings = s;
fMetrics = metrics;
String strkSetting_ZkBasePath= AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,kSetting_ZkBasePath);
if(null==strkSetting_ZkBasePath)strkSetting_ZkBasePath = kDefault_ZkBasePath;
fBaseZkPath = strkSetting_ZkBasePath;
fConsumers = new ConcurrentHashMap<String, KafkaConsumer>();
fSweepScheduler = Executors.newScheduledThreadPool(1);
curatorConsumerCache = null;
status = Status.NOT_STARTED;
listener = new ConnectionStateListener() {
public void stateChanged(CuratorFramework client, ConnectionState newState) {
if (newState == ConnectionState.LOST) {
log.info("ZooKeeper connection expired");
handleConnectionLoss();
} else if (newState == ConnectionState.READ_ONLY) {
log.warn("ZooKeeper connection set to read only mode.");
} else if (newState == ConnectionState.RECONNECTED) {
log.info("ZooKeeper connection re-established");
handleReconnection();
} else if (newState == ConnectionState.SUSPENDED) {
log.warn("ZooKeeper connection has been suspended.");
handleConnectionSuspended();
}
}
};
}
示例8: stateChanged
@Override
public void stateChanged(final CuratorFramework client, final ConnectionState state) {
if (state == ConnectionState.LOST || state == ConnectionState.SUSPENDED) {
log.warn("connection state changed, now");
isStop.set(true);
}
}
示例9: stateChanged
@Override
public void stateChanged(final CuratorFramework client, final ConnectionState newState) {
if (ConnectionState.LOST == newState) {
log.info("Connection lost from zookeeper :server=" + serverLists + ", namespace=" + namespace);
}
if (ConnectionState.RECONNECTED == newState) {
log.info("Reconnection from zookeeper :server=" + serverLists + ", namespace=" + namespace);
}
}
示例10: stateChanged
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
if ((newState == ConnectionState.SUSPENDED) || (newState == ConnectionState.LOST)) {
try {
shutdown();
} catch (SchedulerException e) {
throw new RuntimeException("failed to shutdown scheduler", e);
}
}
}
示例11: stateChanged
@Override
public void stateChanged(CuratorFramework curatorFramework, ConnectionState newState)
{
if ( (newState == ConnectionState.LOST) || (newState == ConnectionState.SUSPENDED) )
{
if ( ourThread != null )
{
ourThread.interrupt();
}
}
}
示例12: stateChanged
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
if (newState == ConnectionState.CONNECTED) {
if (registration == null) {
registration = bundleContext.registerService(CuratorFramework.class, curator, null);
}
}
for (ConnectionStateListener listener : connectionStateListeners) {
listener.stateChanged(client, newState);
}
if (newState == ConnectionState.LOST) {
run();
}
}
示例13: stateChanged
@Override
public void stateChanged(CuratorFramework curatorFramework, ConnectionState newState) {
if (newState == ConnectionState.LOST || newState == ConnectionState.SUSPENDED) {
LOG.debug("Lost leadership due to ZK state change to {}: {}", newState, getId());
closeLeaderLatch();
}
}
示例14: stateChanged
public void stateChanged(CuratorFramework curatorFramework, ConnectionState connectionState) {
log.info("Connection to Zookeeper toggled to state " + connectionState.toString());
connected = connectionState == ConnectionState.CONNECTED || connectionState == ConnectionState.RECONNECTED;
if (connectionState == ConnectionState.LOST) {
log.error("Connection to Zookeeper toggled to state " + connectionState.toString());
this.handleZookeeperConnectionFailed();
} else if (connectionState == ConnectionState.RECONNECTED) {
log.info("Reconnected to zookeeper, forcing lock scavenge");
forceLockScavenge();
} else {
log.info("Connection to Zookeeper toggled to state " + connectionState.toString());
}
}
示例15: stateChanged
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
if (newState == ConnectionState.SUSPENDED || newState == ConnectionState.LOST) {
lastState = newState;
}
}