gpt4 book ai didi

org.apache.gobblin.runtime.locks.ZookeeperBasedJobLock类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 12:45:31 28 4
gpt4 key购买 nike

本文整理了Java中org.apache.gobblin.runtime.locks.ZookeeperBasedJobLock类的一些代码示例,展示了ZookeeperBasedJobLock类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperBasedJobLock类的具体详情如下:
包路径:org.apache.gobblin.runtime.locks.ZookeeperBasedJobLock
类名称: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);
  }
 }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com