当前位置: 首页>>代码示例>>Java>>正文


Java Version.newInstance方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.records.Version.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Version.newInstance方法的具体用法?Java Version.newInstance怎么用?Java Version.newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.server.records.Version的用法示例。


在下文中一共展示了Version.newInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCheckVersion

import org.apache.hadoop.yarn.server.records.Version; //导入方法依赖的package包/类
@Test
public void testCheckVersion() throws IOException {
  // default version
  Version defaultVersion = stateStore.getCurrentVersion();
  Assert.assertEquals(defaultVersion, stateStore.loadVersion());

  // compatible version
  Version compatibleVersion =
      Version.newInstance(defaultVersion.getMajorVersion(),
        defaultVersion.getMinorVersion() + 2);
  stateStore.storeVersion(compatibleVersion);
  Assert.assertEquals(compatibleVersion, stateStore.loadVersion());
  restartStateStore();
  // overwrite the compatible version
  Assert.assertEquals(defaultVersion, stateStore.loadVersion());

  // incompatible version
  Version incompatibleVersion =
    Version.newInstance(defaultVersion.getMajorVersion() + 1,
        defaultVersion.getMinorVersion());
  stateStore.storeVersion(incompatibleVersion);
  try {
    restartStateStore();
    Assert.fail("Incompatible version, should expect fail here.");
  } catch (ServiceStateException e) {
    Assert.assertTrue("Exception message mismatch", 
      e.getMessage().contains("Incompatible version for NM state:"));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestNMLeveldbStateStoreService.java

示例2: testCheckVersion

import org.apache.hadoop.yarn.server.records.Version; //导入方法依赖的package包/类
public void testCheckVersion(RMStateStoreHelper stateStoreHelper)
    throws Exception {
  RMStateStore store = stateStoreHelper.getRMStateStore();
  store.setRMDispatcher(new TestDispatcher());

  // default version
  Version defaultVersion = stateStoreHelper.getCurrentVersion();
  store.checkVersion();
  Assert.assertEquals(defaultVersion, store.loadVersion());

  // compatible version
  Version compatibleVersion =
      Version.newInstance(defaultVersion.getMajorVersion(),
        defaultVersion.getMinorVersion() + 2);
  stateStoreHelper.writeVersion(compatibleVersion);
  Assert.assertEquals(compatibleVersion, store.loadVersion());
  store.checkVersion();
  // overwrite the compatible version
  Assert.assertEquals(defaultVersion, store.loadVersion());

  // incompatible version
  Version incompatibleVersion =
      Version.newInstance(defaultVersion.getMajorVersion() + 2,
        defaultVersion.getMinorVersion());
  stateStoreHelper.writeVersion(incompatibleVersion);
  try {
    store.checkVersion();
    Assert.fail("Invalid version, should fail.");
  } catch (Throwable t) {
    Assert.assertTrue(t instanceof RMStateVersionIncompatibleException);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:RMStateStoreTestBase.java

示例3: testCheckVersion

import org.apache.hadoop.yarn.server.records.Version; //导入方法依赖的package包/类
@Test
public void testCheckVersion() throws IOException {
  LeveldbTimelineStateStore store =
      initAndStartTimelineServiceStateStoreService();
  // default version
  Version defaultVersion = store.getCurrentVersion();
  Assert.assertEquals(defaultVersion, store.loadVersion());

  // compatible version
  Version compatibleVersion =
      Version.newInstance(defaultVersion.getMajorVersion(),
          defaultVersion.getMinorVersion() + 2);
  store.storeVersion(compatibleVersion);
  Assert.assertEquals(compatibleVersion, store.loadVersion());
  store.stop();

  // overwrite the compatible version
  store = initAndStartTimelineServiceStateStoreService();
  Assert.assertEquals(defaultVersion, store.loadVersion());

  // incompatible version
  Version incompatibleVersion =
      Version.newInstance(defaultVersion.getMajorVersion() + 1,
          defaultVersion.getMinorVersion());
  store.storeVersion(incompatibleVersion);
  store.stop();

  try {
    initAndStartTimelineServiceStateStoreService();
    Assert.fail("Incompatible version, should expect fail here.");
  } catch (ServiceStateException e) {
    Assert.assertTrue("Exception message mismatch",
        e.getMessage().contains("Incompatible version for timeline state store"));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:TestLeveldbTimelineStateStore.java

示例4: loadVersion

import org.apache.hadoop.yarn.server.records.Version; //导入方法依赖的package包/类
Version loadVersion() throws IOException {
  byte[] data = db.get(bytes(DB_SCHEMA_VERSION_KEY));
  // if version is not stored previously, treat it as 1.0.
  if (data == null || data.length == 0) {
    return Version.newInstance(1, 0);
  }
  Version version =
      new VersionPBImpl(VersionProto.parseFrom(data));
  return version;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:HistoryServerLeveldbStateStoreService.java

示例5: loadVersion

import org.apache.hadoop.yarn.server.records.Version; //导入方法依赖的package包/类
Version loadVersion() throws IOException {
  byte[] data = starttimedb.get(bytes(TIMELINE_STORE_VERSION_KEY));
  // if version is not stored previously, treat it as 1.0.
  if (data == null || data.length == 0) {
    return Version.newInstance(1, 0);
  }
  Version version = new VersionPBImpl(VersionProto.parseFrom(data));
  return version;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:10,代码来源:RollingLevelDBTimelineStore.java

示例6: testCheckVersion

import org.apache.hadoop.yarn.server.records.Version; //导入方法依赖的package包/类
@Test
public void testCheckVersion() throws IOException {
  RollingLevelDBTimelineStore dbStore = (RollingLevelDBTimelineStore) store;
  // default version
  Version defaultVersion = dbStore.getCurrentVersion();
  Assert.assertEquals(defaultVersion, dbStore.loadVersion());

  // compatible version
  Version compatibleVersion =
      Version.newInstance(defaultVersion.getMajorVersion(),
        defaultVersion.getMinorVersion() + 2);
  dbStore.storeVersion(compatibleVersion);
  Assert.assertEquals(compatibleVersion, dbStore.loadVersion());
  restartTimelineStore();
  dbStore = (RollingLevelDBTimelineStore) store;
  // overwrite the compatible version
  Assert.assertEquals(defaultVersion, dbStore.loadVersion());

  // incompatible version
  Version incompatibleVersion =
      Version.newInstance(defaultVersion.getMajorVersion() + 1,
        defaultVersion.getMinorVersion());
  dbStore.storeVersion(incompatibleVersion);
  try {
    restartTimelineStore();
    Assert.fail("Incompatible version, should expect fail here.");
  } catch (ServiceStateException e) {
    Assert.assertTrue("Exception message mismatch",
        e.getMessage().contains("Incompatible version for timeline store"));
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:32,代码来源:TestRollingLevelDBTimelineStore.java

示例7: testCheckVersion

import org.apache.hadoop.yarn.server.records.Version; //导入方法依赖的package包/类
@Test
public void testCheckVersion() throws IOException {
  LeveldbTimelineStore dbStore = (LeveldbTimelineStore) store;
  // default version
  Version defaultVersion = dbStore.getCurrentVersion();
  Assert.assertEquals(defaultVersion, dbStore.loadVersion());

  // compatible version
  Version compatibleVersion =
      Version.newInstance(defaultVersion.getMajorVersion(),
        defaultVersion.getMinorVersion() + 2);
  dbStore.storeVersion(compatibleVersion);
  Assert.assertEquals(compatibleVersion, dbStore.loadVersion());
  restartTimelineStore();
  dbStore = (LeveldbTimelineStore) store;
  // overwrite the compatible version
  Assert.assertEquals(defaultVersion, dbStore.loadVersion());

  // incompatible version
  Version incompatibleVersion = Version.newInstance(
      defaultVersion.getMajorVersion() + 1, defaultVersion.getMinorVersion());
  dbStore.storeVersion(incompatibleVersion);
  try {
    restartTimelineStore();
    Assert.fail("Incompatible version, should expect fail here.");
  } catch (ServiceStateException e) {
    Assert.assertTrue("Exception message mismatch",
        e.getMessage().contains("Incompatible version for timeline store"));
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:31,代码来源:TestLeveldbTimelineStore.java

示例8: testCheckMajorVersionChange

import org.apache.hadoop.yarn.server.records.Version; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testCheckMajorVersionChange() throws Exception {
  HdfsConfiguration conf = new HdfsConfiguration();
  MiniDFSCluster cluster =
      new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
  try {
    fsTester = new TestFSRMStateStoreTester(cluster, false) {
      Version VERSION_INFO = Version.newInstance(Integer.MAX_VALUE, 0);

      @Override
      public Version getCurrentVersion() throws Exception {
        return VERSION_INFO;
      }

      @Override
      public RMStateStore getRMStateStore() throws Exception {
        YarnConfiguration conf = new YarnConfiguration();
        conf.set(YarnConfiguration.FS_RM_STATE_STORE_URI,
            workingDirPathURI.toString());
        conf.set(YarnConfiguration.FS_RM_STATE_STORE_RETRY_POLICY_SPEC,
            "100,6000");
        this.store = new TestFileSystemRMStore(conf) {
          Version storedVersion = null;

          @Override
          public Version getCurrentVersion() {
            return VERSION_INFO;
          }

          @Override
          protected synchronized Version loadVersion() throws Exception {
            return storedVersion;
          }

          @Override
          protected synchronized void storeVersion() throws Exception {
            storedVersion = VERSION_INFO;
          }
        };
        return store;
      }
    };

    // default version
    RMStateStore store = fsTester.getRMStateStore();
    Version defaultVersion = fsTester.getCurrentVersion();
    store.checkVersion();
    Assert.assertEquals(defaultVersion, store.loadVersion());
  } finally {
    cluster.shutdown();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:53,代码来源:TestFSRMStateStore.java

示例9: testCheckVersion

import org.apache.hadoop.yarn.server.records.Version; //导入方法依赖的package包/类
@Test
public void testCheckVersion() throws IOException {
  HistoryServerLeveldbStateStoreService store =
      new HistoryServerLeveldbStateStoreService();
  store.init(conf);
  store.start();

  // default version
  Version defaultVersion = store.getCurrentVersion();
  assertEquals(defaultVersion, store.loadVersion());

  // compatible version
  Version compatibleVersion =
      Version.newInstance(defaultVersion.getMajorVersion(),
        defaultVersion.getMinorVersion() + 2);
  store.dbStoreVersion(compatibleVersion);
  assertEquals(compatibleVersion, store.loadVersion());
  store.close();
  store = new HistoryServerLeveldbStateStoreService();
  store.init(conf);
  store.start();

  // overwrite the compatible version
  assertEquals(defaultVersion, store.loadVersion());

  // incompatible version
  Version incompatibleVersion =
    Version.newInstance(defaultVersion.getMajorVersion() + 1,
        defaultVersion.getMinorVersion());
  store.dbStoreVersion(incompatibleVersion);
  store.close();
  store = new HistoryServerLeveldbStateStoreService();
  try {
    store.init(conf);
    store.start();
    fail("Incompatible version, should have thrown before here.");
  } catch (ServiceStateException e) {
    assertTrue("Exception message mismatch",
      e.getMessage().contains("Incompatible version for state:"));
  }
  store.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:43,代码来源:TestHistoryServerLeveldbStateStoreService.java


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