- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.helix.manager.zk.ZkClient.<init>()
方法的一些代码示例,展示了ZkClient.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClient.<init>()
方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZkClient
类名称:ZkClient
方法名:<init>
暂无
代码示例来源:origin: apache/incubator-pinot
@Override
public boolean execute()
throws Exception {
LOGGER.info("Connecting to Zookeeper at address: {}", _zkAddress);
ZkClient zkClient = new ZkClient(_zkAddress, 5000);
String helixClusterName = "/" + _clusterName;
LOGGER.info("Executing command: " + toString());
if (!zkClient.exists(helixClusterName)) {
LOGGER.error("Cluster {} does not exist.", _clusterName);
return false;
}
zkClient.deleteRecursive(helixClusterName);
return true;
}
}
代码示例来源:origin: apache/incubator-pinot
public void start(ControllerMetrics controllerMetrics) {
_controllerMetrics = controllerMetrics;
LOGGER.info("Starting realtime segments manager, adding a listener on the property store table configs path.");
String zkUrl = _pinotHelixResourceManager.getHelixZkURL();
_zkClient = new ZkClient(zkUrl, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT);
_zkClient.setZkSerializer(new ZNRecordSerializer());
_zkClient.waitUntilConnected(CommonConstants.Helix.ZkClient.DEFAULT_CONNECT_TIMEOUT_SEC, TimeUnit.SECONDS);
// Subscribe to any data/child changes to property
_zkClient.subscribeChildChanges(_tableConfigPath, this);
_zkClient.subscribeDataChanges(_tableConfigPath, this);
// Subscribe to leadership changes
ControllerLeadershipManager.getInstance().subscribe(PinotLLCRealtimeSegmentManager.class.getName(), this);
// Setup change listeners for already existing tables, if any.
processPropertyStoreChange(_tableConfigPath);
}
代码示例来源:origin: apache/incubator-pinot
StateModelDefinition newStateModelDef =
PinotHelixSegmentOnlineOfflineStateModelGenerator.generatePinotStateModelDefinition();
ZkClient zkClient = new ZkClient(zkPath);
zkClient.waitUntilConnected(CommonConstants.Helix.ZkClient.DEFAULT_CONNECT_TIMEOUT_SEC, TimeUnit.SECONDS);
zkClient.setZkSerializer(new ZNRecordSerializer());
代码示例来源:origin: apache/incubator-pinot
List<String> tables = zkHelixAdmin.getResourcesInCluster(_clusterName);
ZkClient zkClient = new ZkClient(_zkAddress);
zkClient.setZkSerializer(new ZNRecordStreamingSerializer());
LOGGER.info("Connecting to Zookeeper at: {}", _zkAddress);
代码示例来源:origin: apache/incubator-pinot
@BeforeClass
public void setUp()
throws Exception {
_zookeeperInstance = ZkStarter.startLocalZkServer();
_zkClient = new ZkClient(ZkStarter.DEFAULT_ZK_STR);
final String instanceId = "localhost_helixController";
_pinotHelixResourceManager =
new PinotHelixResourceManager(ZkStarter.DEFAULT_ZK_STR, HELIX_CLUSTER_NAME, instanceId, null, 10000L, true,
/*isUpdateStateModel=*/ false, true);
_pinotHelixResourceManager.start();
_helixAdmin = _pinotHelixResourceManager.getHelixAdmin();
ControllerRequestBuilderUtil
.addFakeDataInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZkStarter.DEFAULT_ZK_STR, 1, true);
ControllerRequestBuilderUtil
.addFakeBrokerInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZkStarter.DEFAULT_ZK_STR, 1, true);
Assert.assertEquals(_helixAdmin.getInstancesInClusterWithTag(HELIX_CLUSTER_NAME, "DefaultTenant_BROKER").size(), 1);
Assert
.assertEquals(_helixAdmin.getInstancesInClusterWithTag(HELIX_CLUSTER_NAME, "DefaultTenant_OFFLINE").size(), 1);
Assert
.assertEquals(_helixAdmin.getInstancesInClusterWithTag(HELIX_CLUSTER_NAME, "DefaultTenant_REALTIME").size(), 1);
// Adding table
TableConfig tableConfig =
new TableConfig.Builder(CommonConstants.Helix.TableType.OFFLINE).setTableName(TABLE_NAME).build();
_pinotHelixResourceManager.addTable(tableConfig);
}
代码示例来源:origin: apache/incubator-pinot
FakeHelixManager(String clusterName, String instanceName, InstanceType instanceType, String zkAddress) {
super(clusterName, instanceName, instanceType, zkAddress);
super._zkclient = new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")),
ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
_zkclient.deleteRecursive("/" + clusterName + "/PROPERTYSTORE");
_zkclient.createPersistent("/" + clusterName + "/PROPERTYSTORE", true);
setPropertyStore(clusterName);
}
代码示例来源:origin: apache/incubator-pinot
protected void startController(ControllerConf config) {
Assert.assertNotNull(config);
Assert.assertNull(_controllerStarter);
_controllerPort = Integer.valueOf(config.getControllerPort());
_controllerBaseApiUrl = "http://localhost:" + _controllerPort;
_controllerRequestURLBuilder = ControllerRequestURLBuilder.baseUrl(_controllerBaseApiUrl);
_controllerDataDir = config.getDataDir();
String helixClusterName = getHelixClusterName();
config.setHelixClusterName(helixClusterName);
String zkStr = config.getZkStr();
_zkClient = new ZkClient(zkStr);
if (_zkClient.exists("/" + helixClusterName)) {
_zkClient.deleteRecursive("/" + helixClusterName);
}
startControllerStarter(config);
_helixManager = _helixResourceManager.getHelixZkManager();
_helixAdmin = _helixResourceManager.getHelixAdmin();
_propertyStore = _helixResourceManager.getPropertyStore();
}
代码示例来源:origin: apache/incubator-pinot
@BeforeClass
public void setUp()
throws Exception {
_zookeeperInstance = ZkStarter.startLocalZkServer();
_zkClient = new ZkClient(ZK_STR);
Thread.sleep(1000);
_pinotHelixResourceManager =
new PinotHelixResourceManager(ZK_STR, HELIX_CLUSTER_NAME, CONTROLLER_INSTANCE_NAME, null, 1000L,
true, /*isUpdateStateModel=*/
false, true);
_pinotHelixResourceManager.start();
ControllerRequestBuilderUtil.addFakeDataInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_STR, 2, true);
ControllerRequestBuilderUtil.addFakeBrokerInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_STR, 2, true);
_offlineTableConfig =
new TableConfig.Builder(CommonConstants.Helix.TableType.OFFLINE).setTableName(TEST_TABLE_NAME).setNumReplicas(2)
.build();
final String instanceId = "localhost_helixController";
_helixManager = HelixSetupUtils.setup(HELIX_CLUSTER_NAME, ZK_STR, instanceId, /*isUpdateStateModel=*/false, true);
_pinotHelixResourceManager.addTable(_offlineTableConfig);
}
代码示例来源:origin: apache/incubator-pinot
@BeforeTest
public void beforeTest() {
_zookeeperInstance = ZkStarter.startLocalZkServer();
_zkClient = new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")),
ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
String helixClusterName = "TestTimeBoundaryService";
_zkClient.deleteRecursive("/" + helixClusterName + "/PROPERTYSTORE");
_zkClient.createPersistent("/" + helixClusterName + "/PROPERTYSTORE", true);
_propertyStore = new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<ZNRecord>(_zkClient),
"/" + helixClusterName + "/PROPERTYSTORE", null);
}
代码示例来源:origin: org.apache.helix/helix-core
public ZKDumper(String zkAddress) {
client = new ZkClient(zkAddress, ZkClient.DEFAULT_CONNECTION_TIMEOUT);
ZkSerializer zkSerializer = new ByteArraySerializer();
client.setZkSerializer(zkSerializer);
filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return !name.startsWith(".");
}
};
}
代码示例来源:origin: org.apache.helix/helix-core
private static Map<TestCommand, Boolean> executeTestHelper(List<TestCommand> commandList,
String zkAddr, CountDownLatch countDown) {
final Map<TestCommand, Boolean> testResults = new ConcurrentHashMap<TestCommand, Boolean>();
ZkClient zkClient = null;
zkClient = new ZkClient(zkAddr, ZkClient.DEFAULT_CONNECTION_TIMEOUT);
zkClient.setZkSerializer(new ZNRecordSerializer());
// sort on trigger's start time, stable sort
Collections.sort(commandList, new Comparator<TestCommand>() {
@Override
public int compare(TestCommand o1, TestCommand o2) {
return (int) (o1._trigger._startTime - o2._trigger._startTime);
}
});
for (TestCommand command : commandList) {
testResults.put(command, new Boolean(false));
TestTrigger trigger = command._trigger;
command._startTimestamp = System.currentTimeMillis() + trigger._startTime;
new Thread(new ExecuteCommand(command._startTimestamp, command, countDown, zkClient,
testResults)).start();
}
return testResults;
}
代码示例来源:origin: org.apache.helix/helix-core
public ZKHelixAdmin(String zkAddress) {
int timeOutInSec = Integer.parseInt(System.getProperty(CONNECTION_TIMEOUT, "30"));
_zkClient = new ZkClient(zkAddress, timeOutInSec * 1000);
_zkClient.setZkSerializer(new ZNRecordSerializer());
_zkClient.waitUntilConnected(timeOutInSec, TimeUnit.SECONDS);
_configAccessor = new ConfigAccessor(_zkClient);
}
代码示例来源:origin: org.apache.helix/helix-core
public static ZkClient getZkClient(String zkServer) {
// happy path that we cache the zkclient and it's still connected
if (_zkClientMap.containsKey(zkServer)) {
ZkClient zkClient = _zkClientMap.get(zkServer);
if (zkClient.getConnection().getZookeeperState() == States.CONNECTED) {
return zkClient;
}
}
synchronized (_zkClientMap) {
// if we cache a stale zkclient, purge it
if (_zkClientMap.containsKey(zkServer)) {
ZkClient zkClient = _zkClientMap.get(zkServer);
if (zkClient.getConnection().getZookeeperState() != States.CONNECTED) {
_zkClientMap.remove(zkServer);
}
}
// get a new zkclient
if (!_zkClientMap.containsKey(zkServer)) {
ZkClient zkClient =
new ZkClient(zkServer, DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT,
new ZNRecordSerializer());
_zkClientMap.put(zkServer, zkClient);
}
return _zkClientMap.get(zkServer);
}
}
代码示例来源:origin: apache/helix
@BeforeClass
public void beforeClass() {
_zkClient = new ZkClient(ZK_ADDR);
_zkClient.setZkSerializer(new ZNRecordSerializer());
}
代码示例来源:origin: org.apache.helix/helix-core
public ZkClient build() {
if (_connection == null) {
if (_zkServer == null) {
throw new HelixException(
"Failed to build ZkClient since no connection or ZK server address is specified.");
} else {
_connection = new ZkConnection(_zkServer, _sessionTimeout);
}
}
if (_zkSerializer == null) {
_zkSerializer = new BasicZkSerializer(new SerializableSerializer());
}
return new ZkClient(_connection, _connectionTimeout, _operationRetryTimeout, _zkSerializer,
_monitorType, _monitorKey, _monitorInstanceName, _monitorRootPathOnly);
}
}
代码示例来源:origin: apache/helix
public ZkClient build() {
if (_connection == null) {
if (_zkServer == null) {
throw new HelixException(
"Failed to build ZkClient since no connection or ZK server address is specified.");
} else {
_connection = new ZkConnection(_zkServer, _sessionTimeout);
}
}
if (_zkSerializer == null) {
_zkSerializer = new BasicZkSerializer(new SerializableSerializer());
}
return new ZkClient(_connection, _connectionTimeout, _operationRetryTimeout, _zkSerializer,
_monitorType, _monitorKey, _monitorInstanceName, _monitorRootPathOnly);
}
}
代码示例来源:origin: apache/helix
@Test
public void testCloseZkClient() {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
ZkClient client =
new ZkClient(ZK_ADDR, HelixZkClient.DEFAULT_SESSION_TIMEOUT,
HelixZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
String path = String.format("/%s", clusterName);
client.createEphemeral(path);
client.close();
Assert.assertFalse(_gZkClient.exists(path), "Ephemeral node: " + path
+ " should be removed after ZkClient#close()");
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: apache/helix
@Test
public void testZkSessionExpiry() throws Exception {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
ZkClient client =
new ZkClient(ZK_ADDR, HelixZkClient.DEFAULT_SESSION_TIMEOUT,
HelixZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
String path = String.format("/%s", clusterName);
client.createEphemeral(path);
String oldSessionId = ZkTestHelper.getSessionId(client);
ZkTestHelper.expireSession(client);
String newSessionId = ZkTestHelper.getSessionId(client);
Assert.assertNotSame(newSessionId, oldSessionId);
Assert.assertFalse(client.exists(path), "Ephemeral znode should be gone after session expiry");
client.close();
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: apache/helix
/**
* Build a Dedicated ZkClient based on connection config and client config
*
* @param connectionConfig
* @param clientConfig
* @return
*/
@Override
public HelixZkClient buildZkClient(HelixZkClient.ZkConnectionConfig connectionConfig,
HelixZkClient.ZkClientConfig clientConfig) {
return new ZkClient(createZkConnection(connectionConfig),
(int) clientConfig.getConnectInitTimeout(), clientConfig.getOperationRetryTimeout(),
clientConfig.getZkSerializer(), clientConfig.getMonitorType(), clientConfig.getMonitorKey(),
clientConfig.getMonitorInstanceName(), clientConfig.isMonitorRootPathOnly());
}
}
代码示例来源:origin: org.apache.helix/helix-core
public void post(String zkServer, Message message, String clusterName, String instanceName) {
ZkClient client = new ZkClient(zkServer);
client.setZkSerializer(new ZNRecordSerializer());
String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
client.delete(path);
ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()));
message.setTgtName(record.getId());
// System.out.println(message);
client.createPersistent(path, message.getRecord());
}
我想了解 Ruby 方法 methods() 是如何工作的。 我尝试使用“ruby 方法”在 Google 上搜索,但这不是我需要的。 我也看过 ruby-doc.org,但我没有找到这种方法。
Test 方法 对指定的字符串执行一个正则表达式搜索,并返回一个 Boolean 值指示是否找到匹配的模式。 object.Test(string) 参数 object 必选项。总是一个
Replace 方法 替换在正则表达式查找中找到的文本。 object.Replace(string1, string2) 参数 object 必选项。总是一个 RegExp 对象的名称。
Raise 方法 生成运行时错误 object.Raise(number, source, description, helpfile, helpcontext) 参数 object 应为
Execute 方法 对指定的字符串执行正则表达式搜索。 object.Execute(string) 参数 object 必选项。总是一个 RegExp 对象的名称。 string
Clear 方法 清除 Err 对象的所有属性设置。 object.Clear object 应为 Err 对象的名称。 说明 在错误处理后,使用 Clear 显式地清除 Err 对象。此
CopyFile 方法 将一个或多个文件从某位置复制到另一位置。 object.CopyFile source, destination[, overwrite] 参数 object 必选
Copy 方法 将指定的文件或文件夹从某位置复制到另一位置。 object.Copy destination[, overwrite] 参数 object 必选项。应为 File 或 F
Close 方法 关闭打开的 TextStream 文件。 object.Close object 应为 TextStream 对象的名称。 说明 下面例子举例说明如何使用 Close 方
BuildPath 方法 向现有路径后添加名称。 object.BuildPath(path, name) 参数 object 必选项。应为 FileSystemObject 对象的名称
GetFolder 方法 返回与指定的路径中某文件夹相应的 Folder 对象。 object.GetFolder(folderspec) 参数 object 必选项。应为 FileSy
GetFileName 方法 返回指定路径(不是指定驱动器路径部分)的最后一个文件或文件夹。 object.GetFileName(pathspec) 参数 object 必选项。应为
GetFile 方法 返回与指定路径中某文件相应的 File 对象。 object.GetFile(filespec) 参数 object 必选项。应为 FileSystemObject
GetExtensionName 方法 返回字符串,该字符串包含路径最后一个组成部分的扩展名。 object.GetExtensionName(path) 参数 object 必选项。应
GetDriveName 方法 返回包含指定路径中驱动器名的字符串。 object.GetDriveName(path) 参数 object 必选项。应为 FileSystemObjec
GetDrive 方法 返回与指定的路径中驱动器相对应的 Drive 对象。 object.GetDrive drivespec 参数 object 必选项。应为 FileSystemO
GetBaseName 方法 返回字符串,其中包含文件的基本名 (不带扩展名), 或者提供的路径说明中的文件夹。 object.GetBaseName(path) 参数 object 必
GetAbsolutePathName 方法 从提供的指定路径中返回完整且含义明确的路径。 object.GetAbsolutePathName(pathspec) 参数 object
FolderExists 方法 如果指定的文件夹存在,则返回 True;否则返回 False。 object.FolderExists(folderspec) 参数 object 必选项
FileExists 方法 如果指定的文件存在返回 True;否则返回 False。 object.FileExists(filespec) 参数 object 必选项。应为 FileS
我是一名优秀的程序员,十分优秀!