本文整理了Java中org.apache.gobblin.runtime.locks.ZookeeperBasedJobLock
类的一些代码示例,展示了ZookeeperBasedJobLock
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperBasedJobLock
类的具体详情如下:
包路径:org.apache.gobblin.runtime.locks.ZookeeperBasedJobLock
类名称:ZookeeperBasedJobLock
[英]An implementation of JobLock that uses Zookeeper.
[中]使用Zookeeper的JobLock实现。
代码示例来源:origin: apache/incubator-gobblin
public void run() {
log.info("Shutting down curator framework...");
try {
shutdownCuratorFramework();
log.info("Curator framework shut down.");
} catch (Exception e) {
log.error("Error while shutting down curator framework.", e);
}
}
}
代码示例来源:origin: apache/incubator-gobblin
private static int getMilliseconds(Properties properties, String key, int defaultValue) {
return getInt(properties, key, defaultValue) * 1000;
}
代码示例来源:origin: apache/incubator-gobblin
public ZookeeperBasedJobLock(Properties properties) throws JobLockException {
String jobName = properties.getProperty(ConfigurationKeys.JOB_NAME_KEY);
this.lockAcquireTimeoutMilliseconds =
getLong(properties, LOCKS_ACQUIRE_TIMEOUT_MILLISECONDS, LOCKS_ACQUIRE_TIMEOUT_MILLISECONDS_DEFAULT);
this.lockPath = Paths.get(LOCKS_ROOT_PATH, jobName).toString();
initializeCuratorFramework(properties);
lock = new InterProcessSemaphoreMutex(curatorFramework, lockPath);
}
代码示例来源:origin: apache/incubator-gobblin
.connectString(properties.getProperty(CONNECTION_STRING, CONNECTION_STRING_DEFAULT))
.connectionTimeoutMs(
getMilliseconds(properties, CONNECTION_TIMEOUT_SECONDS, CONNECTION_TIMEOUT_SECONDS_DEFAULT))
.sessionTimeoutMs(
getMilliseconds(properties, SESSION_TIMEOUT_SECONDS, SESSION_TIMEOUT_SECONDS_DEFAULT))
.retryPolicy(new ExponentialBackoffRetry(
getMilliseconds(properties, RETRY_BACKOFF_SECONDS, RETRY_BACKOFF_SECONDS_DEFAULT),
getInt(properties, MAX_RETRY_COUNT, MAX_RETRY_COUNT_DEFAULT)))
.build();
try {
if (!newCuratorFramework.blockUntilConnected(
getInt(properties, CONNECTION_TIMEOUT_SECONDS, CONNECTION_TIMEOUT_SECONDS_DEFAULT),
TimeUnit.SECONDS)) {
throw new RuntimeException("Time out while waiting to connect to zookeeper");
代码示例来源:origin: apache/incubator-gobblin
/**
* Closes this stream and releases any system resources associated
* with it. If the stream is already closed then invoking this
* method has no effect.
*
* @throws IOException if an I/O error occurs
*/
@Override
public void close() throws IOException {
try {
this.unlock();
} catch (JobLockException e) {
throw new IOException(e);
} finally {
lockEventListeners.remove(this.lockPath);
}
}
代码示例来源:origin: apache/incubator-gobblin
@Override
protected JobLock getJobLock() throws JobLockException, IOException {
Properties properties = new Properties();
properties.setProperty(ZookeeperBasedJobLock.CONNECTION_STRING, testingServer.getConnectString());
properties.setProperty(ConfigurationKeys.JOB_NAME_KEY, "ZookeeperBasedJobLockTest-" + System.currentTimeMillis());
properties.setProperty(ZookeeperBasedJobLock.MAX_RETRY_COUNT, "1");
properties.setProperty(ZookeeperBasedJobLock.LOCKS_ACQUIRE_TIMEOUT_MILLISECONDS, "1000");
properties.setProperty(ZookeeperBasedJobLock.RETRY_BACKOFF_SECONDS, "1");
properties.setProperty(ZookeeperBasedJobLock.SESSION_TIMEOUT_SECONDS, "180");
properties.setProperty(ZookeeperBasedJobLock.CONNECTION_TIMEOUT_SECONDS, "30");
ZookeeperBasedJobLock lock = new ZookeeperBasedJobLock(properties);
lock.setEventListener(new JobLockEventListener());
return lock;
}
代码示例来源:origin: org.apache.gobblin/gobblin-runtime
.connectString(properties.getProperty(CONNECTION_STRING, CONNECTION_STRING_DEFAULT))
.connectionTimeoutMs(
getMilliseconds(properties, CONNECTION_TIMEOUT_SECONDS, CONNECTION_TIMEOUT_SECONDS_DEFAULT))
.sessionTimeoutMs(
getMilliseconds(properties, SESSION_TIMEOUT_SECONDS, SESSION_TIMEOUT_SECONDS_DEFAULT))
.retryPolicy(new ExponentialBackoffRetry(
getMilliseconds(properties, RETRY_BACKOFF_SECONDS, RETRY_BACKOFF_SECONDS_DEFAULT),
getInt(properties, MAX_RETRY_COUNT, MAX_RETRY_COUNT_DEFAULT)))
.build();
try {
if (!newCuratorFramework.blockUntilConnected(
getInt(properties, CONNECTION_TIMEOUT_SECONDS, CONNECTION_TIMEOUT_SECONDS_DEFAULT),
TimeUnit.SECONDS)) {
throw new RuntimeException("Time out while waiting to connect to zookeeper");
代码示例来源:origin: org.apache.gobblin/gobblin-runtime
/**
* Closes this stream and releases any system resources associated
* with it. If the stream is already closed then invoking this
* method has no effect.
*
* @throws IOException if an I/O error occurs
*/
@Override
public void close() throws IOException {
try {
this.unlock();
} catch (JobLockException e) {
throw new IOException(e);
} finally {
lockEventListeners.remove(this.lockPath);
}
}
代码示例来源:origin: apache/incubator-gobblin
@AfterClass
public void tearDown() throws IOException {
ZookeeperBasedJobLock.shutdownCuratorFramework();
}
代码示例来源:origin: org.apache.gobblin/gobblin-runtime
public ZookeeperBasedJobLock(Properties properties) throws JobLockException {
String jobName = properties.getProperty(ConfigurationKeys.JOB_NAME_KEY);
this.lockAcquireTimeoutMilliseconds =
getLong(properties, LOCKS_ACQUIRE_TIMEOUT_MILLISECONDS, LOCKS_ACQUIRE_TIMEOUT_MILLISECONDS_DEFAULT);
this.lockPath = Paths.get(LOCKS_ROOT_PATH, jobName).toString();
initializeCuratorFramework(properties);
lock = new InterProcessSemaphoreMutex(curatorFramework, lockPath);
}
代码示例来源:origin: org.apache.gobblin/gobblin-runtime
private static int getMilliseconds(Properties properties, String key, int defaultValue) {
return getInt(properties, key, defaultValue) * 1000;
}
代码示例来源:origin: apache/incubator-gobblin
@AfterClass
public void tearDown() throws IOException {
ZookeeperBasedJobLock.shutdownCuratorFramework();
}
代码示例来源:origin: org.apache.gobblin/gobblin-runtime
public void run() {
log.info("Shutting down curator framework...");
try {
shutdownCuratorFramework();
log.info("Curator framework shut down.");
} catch (Exception e) {
log.error("Error while shutting down curator framework.", e);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!