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


Java ServiceStateException类代码示例

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


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

示例1: serviceInit

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
/**
 * Init the service: this sets up security based on the configuration
 * @param conf configuration
 * @throws Exception
 */
@Override
protected void serviceInit(Configuration conf) throws Exception {
  super.serviceInit(conf);
  String auth = conf.getTrimmed(KEY_REGISTRY_CLIENT_AUTH,
      REGISTRY_CLIENT_AUTH_ANONYMOUS);

  switch (auth) {
  case REGISTRY_CLIENT_AUTH_KERBEROS:
    access = AccessPolicy.sasl;
    break;
  case REGISTRY_CLIENT_AUTH_DIGEST:
    access = AccessPolicy.digest;
    break;
  case REGISTRY_CLIENT_AUTH_ANONYMOUS:
    access = AccessPolicy.anon;
    break;
  default:
    throw new ServiceStateException(E_UNKNOWN_AUTHENTICATION_MECHANISM
                                    + "\"" + auth + "\"");
  }
  initSecurity();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:RegistrySecurity.java

示例2: serviceInit

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
/**
 * Init the service: this sets up security based on the configuration
 * @param conf configuration
 * @throws Exception
 */
@Override
protected void serviceInit(Configuration conf) throws Exception {
  super.serviceInit(conf);
  String auth = conf.getTrimmed(KEY_REGISTRY_CLIENT_AUTH,
      REGISTRY_CLIENT_AUTH_ANONYMOUS);

  // TODO JDK7 SWITCH
  if (REGISTRY_CLIENT_AUTH_KERBEROS.equals(auth)) {
    access = AccessPolicy.sasl;
  } else if (REGISTRY_CLIENT_AUTH_DIGEST.equals(auth)) {
    access = AccessPolicy.digest;
  } else if (REGISTRY_CLIENT_AUTH_ANONYMOUS.equals(auth)) {
    access = AccessPolicy.anon;
  } else {
    throw new ServiceStateException(E_UNKNOWN_AUTHENTICATION_MECHANISM
                                    + "\"" + auth + "\"");
  }
  initSecurity();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:25,代码来源:RegistrySecurity.java

示例3: testStopBeforeStart

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
@Test
public void testStopBeforeStart() throws Throwable {
  pauseMonitor = new JvmPauseMonitor();
  try {
    pauseMonitor.init(new Configuration());
    pauseMonitor.stop();
    pauseMonitor.start();
    Assert.fail("Expected an exception, got " + pauseMonitor);
  } catch (ServiceStateException e) {
    GenericTestUtils.assertExceptionContains("cannot enter state", e);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:13,代码来源:TestJvmMetrics.java

示例4: testStopBeforeInit

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
@Test
public void testStopBeforeInit() throws Throwable {
  pauseMonitor = new JvmPauseMonitor();
  try {
    pauseMonitor.stop();
    pauseMonitor.init(new Configuration());
    Assert.fail("Expected an exception, got " + pauseMonitor);
  } catch (ServiceStateException e) {
    GenericTestUtils.assertExceptionContains("cannot enter state", e);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:12,代码来源:TestJvmMetrics.java

示例5: testInitNullConf

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
@Test
public void testInitNullConf() throws Throwable {
  BreakableService svc = new BreakableService(false, false, false);
  try {
    svc.init(null);
    LOG.warn("Null Configurations are permitted ");
  } catch (ServiceStateException e) {
    //expected
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:TestServiceLifecycle.java

示例6: testCheckVersion

import org.apache.hadoop.service.ServiceStateException; //导入依赖的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

示例7: testCheckVersion

import org.apache.hadoop.service.ServiceStateException; //导入依赖的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

示例8: checkServiceLive

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
/**
 * Internal check that a service is in the live state
 * @throws ServiceStateException if not
 */
private void checkServiceLive() throws ServiceStateException {
  if (!isInState(STATE.STARTED)) {
    throw new ServiceStateException(
        "Service " + getName() + " is in wrong state: "
        + getServiceState());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:CuratorService.java

示例9: verifyRealmValidity

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
/**
 * Method to validate the validity of the kerberos realm.
 * <ul>
 *   <li>Insecure: not needed.</li>
 *   <li>Secure: must have been determined.</li>
 * </ul>
 */
protected void verifyRealmValidity() throws ServiceStateException {
  if (isSecure()) {
    String realm = getRegistrySecurity().getKerberosRealm();
    if (StringUtils.isEmpty(realm)) {
      throw new ServiceStateException("Cannot determine service realm");
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("Started Registry operations in realm {}", realm);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:RegistryAdminService.java

示例10: testNoDigestAuthMissingId2

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
@Test(expected = ServiceStateException.class)
public void testNoDigestAuthMissingId2() throws Throwable {
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTH, REGISTRY_CLIENT_AUTH_DIGEST);
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, "");
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD, "pass");
  RegistryOperationsFactory.createInstance("DigestRegistryOperations",
      zkClientConf);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestSecureRMRegistryOperations.java

示例11: testNoDigestAuthMissingPass2

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
@Test(expected = ServiceStateException.class)
public void testNoDigestAuthMissingPass2() throws Throwable {
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTH, REGISTRY_CLIENT_AUTH_DIGEST);
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, "id");
  zkClientConf.set(KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD, "");
  RegistryOperationsFactory.createInstance("DigestRegistryOperations",
      zkClientConf);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestSecureRMRegistryOperations.java

示例12: initilizeServiceFailTest

import org.apache.hadoop.service.ServiceStateException; //导入依赖的package包/类
private void initilizeServiceFailTest(String message,
    ScriptBasedNodeLabelsProvider nodeLabelsProvider) {
  try {
    nodeLabelsProvider.init(new Configuration());
    Assert.fail(message);
  } catch (ServiceStateException ex) {
    Assert.assertEquals("IOException was expected", IOException.class,
        ex.getCause().getClass());
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:11,代码来源:TestScriptBasedNodeLabelsProvider.java

示例13: testCheckVersion

import org.apache.hadoop.service.ServiceStateException; //导入依赖的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

示例14: testCheckVersion

import org.apache.hadoop.service.ServiceStateException; //导入依赖的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


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