• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BindFlags类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.registry.client.api.BindFlags的典型用法代码示例。如果您正苦于以下问题:Java BindFlags类的具体用法?Java BindFlags怎么用?Java BindFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BindFlags类属于org.apache.hadoop.registry.client.api包,在下文中一共展示了BindFlags类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testChildDeletion

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
@Test
public void testChildDeletion() throws Throwable {
  ServiceRecord app = createRecord("app1",
      PersistencePolicies.APPLICATION, "app",
      null);
  ServiceRecord container = createRecord("container1",
      PersistencePolicies.CONTAINER, "container",
      null);

  operations.bind("/app", app, BindFlags.OVERWRITE);
  operations.bind("/app/container", container, BindFlags.OVERWRITE);

  try {
    int p = purge("/",
        "app1",
        PersistencePolicies.APPLICATION,
        RegistryAdminService.PurgePolicy.FailOnChildren);
    fail("expected a failure, got a purge count of " + p);
  } catch (PathIsNotEmptyDirectoryException expected) {
    // expected
  }

}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestRegistryRMOperations.java


示例2: testOverwrite

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
@Test
public void testOverwrite() throws Throwable {
  ServiceRecord written = putExampleServiceEntry(ENTRY_PATH, 0);
  ServiceRecord resolved1 = operations.resolve(ENTRY_PATH);
  resolved1.description = "resolved1";
  try {
    operations.bind(ENTRY_PATH, resolved1, 0);
    fail("overwrite succeeded when it should have failed");
  } catch (FileAlreadyExistsException expected) {
    // expected
  }

  // verify there's no changed
  ServiceRecord resolved2 = operations.resolve(ENTRY_PATH);
  assertMatches(written, resolved2);
  operations.bind(ENTRY_PATH, resolved1, BindFlags.OVERWRITE);
  ServiceRecord resolved3 = operations.resolve(ENTRY_PATH);
  assertMatches(resolved1, resolved3);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestRegistryOperations.java


示例3: needUpgrade

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
public boolean needUpgrade() {
    String containerPath = RegistryUtils.componentPath(
            JOYConstants.APP_TYPE, this.executorMeta.getInstanceName(),
            this.executorMeta.getApplicationId(), this.executorMeta.getRunningContainer());

    try {
        if (registryOperations.exists(containerPath)) {
            ServiceRecord sr = registryOperations.resolve(containerPath);
            if (sr.get(JOYConstants.NEED_UPGRADE) != null && sr.get(JOYConstants.NEED_UPGRADE).equals(JOYConstants.TRUE)) {
                sr.set(JOYConstants.NEED_UPGRADE, JOYConstants.FALSE);
                registryOperations.bind(containerPath, sr, BindFlags.OVERWRITE);
                LOG.info(JOYConstants.NEED_UPGRADE);
                return true;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:21,代码来源:Executor.java


示例4: bind

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
@Override
public void bind(String path,
    ServiceRecord record,
    int flags) throws IOException {
  Preconditions.checkArgument(record != null, "null record");
  validatePath(path);
  // validate the record before putting it
  RegistryTypeUtils.validateServiceRecord(path, record);
  LOG.info("Bound at {} : {}", path, record);

  CreateMode mode = CreateMode.PERSISTENT;
  byte[] bytes = serviceRecordMarshal.toBytes(record);
  zkSet(path, mode, bytes, getClientAcls(),
      ((flags & BindFlags.OVERWRITE) != 0));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:RegistryOperationsService.java


示例5: testPutGetContainerPersistenceServiceEntry

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
@Test
public void testPutGetContainerPersistenceServiceEntry() throws Throwable {

  String path = ENTRY_PATH;
  ServiceRecord written = buildExampleServiceEntry(
      PersistencePolicies.CONTAINER);

  operations.mknode(RegistryPathUtils.parentOf(path), true);
  operations.bind(path, written, BindFlags.CREATE);
  ServiceRecord resolved = operations.resolve(path);
  validateEntry(resolved);
  assertMatches(written, resolved);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestRegistryRMOperations.java


示例6: testPutMinimalRecord

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
@Test
public void testPutMinimalRecord() throws Throwable {
  String path = "/path/with/minimal";
  operations.mknode(path, true);
  ServiceRecord record = new ServiceRecord();
  operations.bind(path, record, BindFlags.OVERWRITE);
  ServiceRecord resolve = operations.resolve(path);
  assertMatches(record, resolve);

}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestRegistryOperations.java


示例7: putComponent

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
/**
 * Add a component 
 * @param serviceClass service class to use under ~user
 * @param componentName component name
 * @param record record to put
 * @throws IOException
 */
public void putComponent(String serviceClass,
    String serviceName,
    String componentName,
    ServiceRecord record) throws IOException {
  String path = RegistryUtils.componentPath(
      user, serviceClass, serviceName, componentName);
  registryOperations.mknode(RegistryPathUtils.parentOf(path), true);
  registryOperations.bind(path, record, BindFlags.OVERWRITE);
}
 
开发者ID:apache,项目名称:incubator-slider,代码行数:17,代码来源:YarnRegistryViewForProviders.java


示例8: putService

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
/**
 * Add a service under a path, optionally purging any history
 * @param username user
 * @param serviceClass service class to use under ~user
 * @param serviceName name of the service
 * @param record service record
 * @param deleteTreeFirst perform recursive delete of the path first.
 * @return the path the service was created at
 * @throws IOException
 */
public String putService(String username,
    String serviceClass,
    String serviceName,
    ServiceRecord record,
    boolean deleteTreeFirst) throws IOException {
  String path = RegistryUtils.servicePath(
      username, serviceClass, serviceName);
  if (deleteTreeFirst) {
    registryOperations.delete(path, true);
  }
  registryOperations.mknode(RegistryPathUtils.parentOf(path), true);
  registryOperations.bind(path, record, BindFlags.OVERWRITE);
  return path;
}
 
开发者ID:apache,项目名称:incubator-slider,代码行数:25,代码来源:YarnRegistryViewForProviders.java


示例9: tryHostLock

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
/**
 * see if anyone is updating host's port list, if not start , update this host itself
 * timeout is 45 seconds
 *
 * @param hostPath
 * @throws InterruptedException
 * @throws IOException
 */
private void tryHostLock(String hostPath) throws Exception {

    //if path has created 60 seconds ago, then delete
    if (registryOperations.exists(hostPath)) {
        try {
            ServiceRecord host = registryOperations.resolve(hostPath);
            Long cTime = Long.parseLong(host.get(JOYConstants.CTIME, JOYConstants.DEFAULT_CTIME));
            Date now = new Date();
            if (now.getTime() - cTime > JOYConstants.HOST_LOCK_TIMEOUT || cTime > now.getTime())
                registryOperations.delete(hostPath, true);
        } catch (Exception ex) {
            LOG.error(ex);
        }
    }

    int failedCount = JOYConstants.RETRY_TIMES;
    while (!registryOperations.mknode(hostPath, true)) {
        Thread.sleep(JOYConstants.SLEEP_INTERVAL);
        failedCount--;
        if (failedCount <= 0)
            break;
    }

    if (failedCount > 0) {
        ServiceRecord sr = new ServiceRecord();
        Date date = new Date();
        date.getTime();
        sr.set(JOYConstants.CTIME, String.valueOf(date.getTime()));
        registryOperations.bind(hostPath, sr, BindFlags.OVERWRITE);
        return;
    }
    throw new Exception("can't get host lock");
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:42,代码来源:SlotPortsView.java


示例10: tryHostLock

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
/**
     * see if anyone is updating host's port list, if not start , update this host itself
     * timeout is 45 seconds
     *
     * @throws InterruptedException
     * @throws IOException
     */
    private void tryHostLock() throws Exception {

        String hostPath = getHostPath();
        //if path has created 60 seconds ago, then delete
        if (registryOperations.exists(hostPath)) {
            try {
                ServiceRecord host = registryOperations.resolve(hostPath);
                Long cTime = Long.parseLong(host.get("cTime", "0"));
                Date now = new Date();
                if (now.getTime() - cTime > 60 * 1000 || cTime > now.getTime())
                    registryOperations.delete(hostPath, true);
            } catch (Exception ex) {
                LOG.error(ex);
//                registryOperations.delete(hostPath, true);
            }
        }

        int failedCount = 45;
        while (!registryOperations.mknode(hostPath, true)) {
            Thread.sleep(1000);
            failedCount--;
            if (failedCount <= 0)
                break;
        }

        if (failedCount > 0) {
            ServiceRecord sr = new ServiceRecord();
            Date date = new Date();
            date.getTime();
            sr.set("cTime", String.valueOf(date.getTime()));
            registryOperations.bind(hostPath, sr, BindFlags.OVERWRITE);
            return;
        }


        throw new Exception("can't get host lock");
    }
 
开发者ID:alibaba,项目名称:jstorm,代码行数:45,代码来源:ContainersView.java


示例11: putService

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
private void putService() throws IOException {
  String path = RegistryUtils.servicePath(user, serviceClass, appIdAsName);
  registryOperations.mknode(RegistryPathUtils.parentOf(path), true);
  registryOperations.bind(path, appRecord, BindFlags.OVERWRITE);
}
 
开发者ID:intel-hadoop,项目名称:yacop,代码行数:6,代码来源:NRegistryOperator.java


示例12: putComponent

import org.apache.hadoop.registry.client.api.BindFlags; //导入依赖的package包/类
private void putComponent(String containerIdAsName) throws IOException {
  String path = RegistryUtils.componentPath(user, serviceClass, appIdAsName, containerIdAsName);
  registryOperations.mknode(RegistryPathUtils.parentOf(path), true);
  registryOperations.bind(path, containerRecords.get(containerIdAsName), BindFlags.OVERWRITE);
}
 
开发者ID:intel-hadoop,项目名称:yacop,代码行数:6,代码来源:NRegistryOperator.java



注:本文中的org.apache.hadoop.registry.client.api.BindFlags类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IBackground类代码示例发布时间:2022-05-23
下一篇:
Java JFXTreeTableColumn类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap