本文整理了Java中org.apache.helix.manager.zk.ZKHelixManager
类的一些代码示例,展示了ZKHelixManager
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKHelixManager
类的具体详情如下:
包路径:org.apache.helix.manager.zk.ZKHelixManager
类名称:ZKHelixManager
暂无
代码示例来源:origin: apache/incubator-pinot
public MinionStarter(String zkAddress, String helixClusterName, Configuration config)
throws Exception {
_helixClusterName = helixClusterName;
_config = config;
_instanceId = config.getString(CommonConstants.Helix.Instance.INSTANCE_ID_KEY,
CommonConstants.Minion.INSTANCE_PREFIX + NetUtil.getHostAddress() + "_"
+ CommonConstants.Minion.DEFAULT_HELIX_PORT);
_helixManager = new ZKHelixManager(_helixClusterName, _instanceId, InstanceType.PARTICIPANT, zkAddress);
_taskExecutorFactoryRegistry = new TaskExecutorFactoryRegistry();
_eventObserverFactoryRegistry = new EventObserverFactoryRegistry();
}
代码示例来源:origin: apache/helix
new ZKHelixManager(clusterName, null, InstanceType.CONTROLLER, ZK_ADDR);
controller.connect();
Assert.fail("Should throw HelixException if initial cluster structure is not setup");
} catch (HelixException e) {
controller.connect();
AssertJUnit.assertTrue(controller.isConnected());
controller.connect();
AssertJUnit.assertTrue(controller.isConnected());
controller.addControllerListener(null);
Assert.fail("Should throw HelixException");
} catch (HelixException e) {
Builder keyBuilder = new Builder(controller.getClusterName());
controller.addControllerListener(listener);
AssertJUnit.assertTrue(listener.isControllerChangeListenerInvoked);
controller.removeListener(keyBuilder.controller(), listener);
ZkHelixPropertyStore<ZNRecord> store = controller.getHelixPropertyStore();
ZNRecord record = new ZNRecord("node_1");
int options = 0;
controller.getMessagingService();
controller.getClusterManagmentTool();
controller.handleNewSession();
controller.disconnect();
代码示例来源:origin: apache/helix
new ZKHelixManager(clusterName, null, InstanceType.ADMINISTRATOR, ZK_ADDR);
admin.connect();
AssertJUnit.assertTrue(admin.isConnected());
HelixAdmin adminTool = admin.getClusterManagmentTool();
HelixConfigScope scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.PARTITION).forCluster(clusterName)
Assert.assertEquals(properties.get("pKey2"), "pValue2");
admin.disconnect();
AssertJUnit.assertFalse(admin.isConnected());
代码示例来源:origin: apache/helix
new ZKHelixManager(clusterName, "localhost_0", InstanceType.PARTICIPANT, ZK_ADDR);
manager.connect();
HelixDataAccessor accessor = manager.getHelixDataAccessor();
Assert.assertTrue(liveInstance.getRecord().getSimpleFields().size() == 3);
manager.disconnect();
manager = new ZKHelixManager(clusterName, "localhost_1", InstanceType.PARTICIPANT, ZK_ADDR);
manager.setLiveInstanceInfoProvider(new provider(false));
manager.connect();
accessor = manager.getHelixDataAccessor();
Assert.assertTrue(liveInstance.getRecord().getSimpleFields().size() == 4);
manager.disconnect();
manager = new ZKHelixManager(clusterName, "localhost_2", InstanceType.PARTICIPANT, ZK_ADDR);
manager.setLiveInstanceInfoProvider(new provider(true));
manager.connect();
accessor = manager.getHelixDataAccessor();
manager.disconnect();
manager2.disconnect();
deleteCluster(clusterName);
代码示例来源:origin: apache/helix
Assert.assertEquals(controller.getMetadataStoreConnectionString(), zkAddr);
controller.connect();
Assert.assertTrue(controller._zkclient
.waitUntilConnected(HelixZkClient.DEFAULT_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS));
Assert.assertTrue(controller.isConnected());
ZkHelixPropertyStore propertyStore = controller.getHelixPropertyStore();
propertyStore.get("/", null, 0);
controller.handleSessionEstablishmentError(new Exception("For testing"));
TestHelper.verify(new TestHelper.Verifier() {
@Override
Assert.assertFalse(controller.isConnected());
controller.getHelixPropertyStore();
} catch (HelixException e) {
controller.disconnect();
zkServer.shutdown();
System.clearProperty(SystemPropertyKeys.ZK_CONNECTION_TIMEOUT);
代码示例来源:origin: apache/helix
String controllerName = "controller_" + i;
ZKHelixManager manager =
new ZKHelixManager(clusterName, controllerName, InstanceType.CONTROLLER, ZK_ADDR);
GenericHelixController controller0 = new GenericHelixController();
DistributedLeaderElection election =
new DistributedLeaderElection(manager, controller0, Collections.EMPTY_LIST);
manager.connect();
managerList.put(manager.getInstanceName(), manager);
代码示例来源:origin: uber/uReplicator
ZKHelixManager managerWorkerHelix = new ZKHelixManager(managerWorkerHelixName, instanceId,
InstanceType.PARTICIPANT, zkServer);
StateMachineEngine stateMachineEngine = managerWorkerHelix.getStateMachineEngine();
ManagerWorkerHelixHandler managerWorkerHandler = new ManagerWorkerHelixHandler(mirrorMakerWorker, workerConf, options);
managerWorkerHelix.connect();
} catch (Exception e) {
e.printStackTrace();
代码示例来源:origin: apache/helix
ZKHelixManager zkHelixManager = new ZKHelixManager(clusterName, "controllerMessageListener", InstanceType.CONTROLLER, ZK_ADDR);
zkHelixManager.connect();
MockMessageListener mockMessageListener = new MockMessageListener();
zkHelixManager.addControllerMessageListener(mockMessageListener);
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void connect() throws Exception {
LOG.info("ClusterManager.connect()");
if (isConnected()) {
LOG.warn("Cluster manager: " + _instanceName + " for cluster: " + _clusterName
+ " already connected. skip connect");
createClient();
_messagingService.onConnected();
} catch (Exception e) {
LOG.error("fail to connect " + _instanceName, e);
try {
disconnect();
} catch (Exception ex) {
代码示例来源:origin: apache/helix
if (isFlapping()) {
String errorMsg = "instanceName: " + _instanceName + " is flapping. disconnect it. "
+ " maxDisconnectThreshold: " + _maxDisconnectThreshold + " disconnects in "
+ " is flapping. Since it is a participant, disable it.");
try {
getClusterManagmentTool().enableInstance(_clusterName, _instanceName, false);
} catch (Exception e) {
LOG.error("Failed to disable participant before disconnecting participant.", e);
disconnect();
} catch (Exception ex) {
LOG.error("Disconnect HelixManager is not completely done.", ex);
代码示例来源:origin: org.apache.helix/helix-core
_baseDataAccessor = createBaseDataAccessor();
addBuiltInStateModelDefinitions();
try {
_zkclient.waitUntilConnected(_connectionInitTimeout, TimeUnit.MILLISECONDS);
handleStateChanged(KeeperState.SyncConnected);
handleNewSession();
break;
} catch (HelixException e) {
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void handleSessionEstablishmentError(Throwable error) throws Exception {
LOG.warn("Handling Session Establishment Error. Disconnect Helix Manager.", error);
disconnect();
if (_stateListener != null) {
_stateListener.onDisconnected(this, error);
}
}
代码示例来源:origin: apache/helix
if (!isConnected()) {
LOG.warn(String.format("%s HelixManager is not connected", warnLogPrefix));
return false;
代码示例来源:origin: apache/helix
@Override
public void handleNewSession() throws Exception {
newSessionHandlingCount.acquire();
super.handleNewSession();
}
代码示例来源:origin: apache/helix
@Override
public void connect() throws Exception {
LOG.info("ClusterManager.connect()");
if (isConnected()) {
LOG.warn("Cluster manager: " + _instanceName + " for cluster: " + _clusterName
+ " already connected. skip connect");
createClient();
_messagingService.onConnected();
} catch (Exception e) {
LOG.error("fail to connect " + _instanceName, e);
try {
disconnect();
} catch (Exception ex) {
代码示例来源:origin: org.apache.helix/helix-core
if (isFlapping()) {
String errorMsg = "instanceName: " + _instanceName + " is flapping. disconnect it. "
+ " maxDisconnectThreshold: " + _maxDisconnectThreshold + " disconnects in "
+ " is flapping. Since it is a participant, disable it.");
try {
getClusterManagmentTool().enableInstance(_clusterName, _instanceName, false);
} catch (Exception e) {
LOG.error("Failed to disable participant before disconnecting participant.", e);
disconnect();
} catch (Exception ex) {
LOG.error("Disconnect HelixManager is not completely done.", ex);
代码示例来源:origin: apache/helix
_baseDataAccessor = createBaseDataAccessor();
addBuiltInStateModelDefinitions();
try {
_zkclient.waitUntilConnected(_connectionInitTimeout, TimeUnit.MILLISECONDS);
handleStateChanged(KeeperState.SyncConnected);
handleNewSession();
break;
} catch (HelixException e) {
代码示例来源:origin: apache/helix
@Override
public void handleSessionEstablishmentError(Throwable error) throws Exception {
LOG.warn("Handling Session Establishment Error. Disconnect Helix Manager.", error);
disconnect();
if (_stateListener != null) {
_stateListener.onDisconnected(this, error);
}
}
代码示例来源:origin: org.apache.helix/helix-core
/**
* Check if HelixManager is connected, if it is not connected,
* wait for the specified timeout and check again before return.
*
* @param timeout
*/
void checkConnected(long timeout) {
if (_zkclient == null || _zkclient.isClosed()) {
throw new HelixException(
"HelixManager (ZkClient) is not connected. Call HelixManager#connect()");
}
boolean isConnected = isConnected();
if (!isConnected && timeout > 0) {
LOG.warn(
"zkClient to " + _zkAddress + " is not connected, wait for " + _waitForConnectedTimeout
+ "ms.");
isConnected = _zkclient.waitUntilConnected(_waitForConnectedTimeout, TimeUnit.MILLISECONDS);
}
if (!isConnected) {
LOG.error("zkClient is not connected after waiting " + timeout + "ms."
+ ", clusterName: " + _clusterName + ", zkAddress: " + _zkAddress);
throw new HelixException(
"HelixManager is not connected within retry timeout for cluster " + _clusterName);
}
}
代码示例来源:origin: org.apache.helix/helix-core
/**
* Construct a zk-based cluster manager that enforces all types (PARTICIPANT, CONTROLLER, and
* SPECTATOR) to have a name
* @param clusterName
* @param instanceName
* @param type
* @param zkAddr
* @return a HelixManager backed by Zookeeper
*/
public static HelixManager getZKHelixManager(String clusterName, String instanceName,
InstanceType type, String zkAddr) {
return new ZKHelixManager(clusterName, instanceName, type, zkAddr);
}
内容来源于网络,如有侵权,请联系作者删除!