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


Java DBException类代码示例

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


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

示例1: startInternal

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
protected void startInternal() throws Exception {
  Path storeRoot = createStorageDir();
  Options options = new Options();
  options.createIfMissing(false);
  options.logger(new LeveldbLogger());
  LOG.info("Using state database at " + storeRoot + " for recovery");
  File dbfile = new File(storeRoot.toString());
  try {
    db = JniDBFactory.factory.open(dbfile, options);
  } catch (NativeDB.DBException e) {
    if (e.isNotFound() || e.getMessage().contains(" does not exist ")) {
      LOG.info("Creating state database at " + dbfile);
      options.createIfMissing(true);
      try {
        db = JniDBFactory.factory.open(dbfile, options);
        // store version
        storeVersion();
      } catch (DBException dbErr) {
        throw new IOException(dbErr.getMessage(), dbErr);
      }
    } else {
      throw e;
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:LeveldbRMStateStore.java

示例2: storeContainer

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
public void storeContainer(ContainerId containerId,
    StartContainerRequest startRequest) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("storeContainer: containerId= " + containerId
        + ", startRequest= " + startRequest);
  }

  String key = CONTAINERS_KEY_PREFIX + containerId.toString()
      + CONTAINER_REQUEST_KEY_SUFFIX;
  try {
    db.put(bytes(key),
      ((StartContainerRequestPBImpl) startRequest).getProto().toByteArray());
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:NMLeveldbStateStoreService.java

示例3: storeContainerDiagnostics

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
public void storeContainerDiagnostics(ContainerId containerId,
    StringBuilder diagnostics) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("storeContainerDiagnostics: containerId=" + containerId
    + ", diagnostics=" + diagnostics);
  }

  String key = CONTAINERS_KEY_PREFIX + containerId.toString()
      + CONTAINER_DIAGS_KEY_SUFFIX;
  try {
    db.put(bytes(key), bytes(diagnostics.toString()));
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:NMLeveldbStateStoreService.java

示例4: removeContainer

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
public void removeContainer(ContainerId containerId)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("removeContainer: containerId=" + containerId);
  }

  String keyPrefix = CONTAINERS_KEY_PREFIX + containerId.toString();
  try {
    WriteBatch batch = db.createWriteBatch();
    try {
      batch.delete(bytes(keyPrefix + CONTAINER_REQUEST_KEY_SUFFIX));
      batch.delete(bytes(keyPrefix + CONTAINER_DIAGS_KEY_SUFFIX));
      batch.delete(bytes(keyPrefix + CONTAINER_LAUNCHED_KEY_SUFFIX));
      batch.delete(bytes(keyPrefix + CONTAINER_KILLED_KEY_SUFFIX));
      batch.delete(bytes(keyPrefix + CONTAINER_EXIT_CODE_KEY_SUFFIX));
      db.write(batch);
    } finally {
      batch.close();
    }
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:NMLeveldbStateStoreService.java

示例5: removeApplication

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
public void removeApplication(ApplicationId appId)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("removeApplication: appId=" + appId);
  }

  try {
    WriteBatch batch = db.createWriteBatch();
    try {
      String key = APPLICATIONS_KEY_PREFIX + appId;
      batch.delete(bytes(key));
      key = FINISHED_APPS_KEY_PREFIX + appId;
      batch.delete(bytes(key));
      db.write(batch);
    } finally {
      batch.close();
    }
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:NMLeveldbStateStoreService.java

示例6: finishResourceLocalization

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
public void finishResourceLocalization(String user, ApplicationId appId,
    LocalizedResourceProto proto) throws IOException {
  String localPath = proto.getLocalPath();
  String startedKey = getResourceStartedKey(user, appId, localPath);
  String completedKey = getResourceCompletedKey(user, appId, localPath);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Storing localized resource to " + completedKey);
  }
  try {
    WriteBatch batch = db.createWriteBatch();
    try {
      batch.delete(bytes(startedKey));
      batch.put(bytes(completedKey), proto.toByteArray());
      db.write(batch);
    } finally {
      batch.close();
    }
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:NMLeveldbStateStoreService.java

示例7: removeLocalizedResource

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
public void removeLocalizedResource(String user, ApplicationId appId,
    Path localPath) throws IOException {
  String localPathStr = localPath.toString();
  String startedKey = getResourceStartedKey(user, appId, localPathStr);
  String completedKey = getResourceCompletedKey(user, appId, localPathStr);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Removing local resource at " + localPathStr);
  }
  try {
    WriteBatch batch = db.createWriteBatch();
    try {
      batch.delete(bytes(startedKey));
      batch.delete(bytes(completedKey));
      db.write(batch);
    } finally {
      batch.close();
    }
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:NMLeveldbStateStoreService.java

示例8: getAndIncrementEpoch

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
public synchronized long getAndIncrementEpoch() throws Exception {
  long currentEpoch = 0;
  byte[] dbKeyBytes = bytes(EPOCH_NODE);
  try {
    byte[] data = db.get(dbKeyBytes);
    if (data != null) {
      currentEpoch = EpochProto.parseFrom(data).getEpoch();
    }
    EpochProto proto = Epoch.newInstance(currentEpoch + 1).getProto();
    db.put(dbKeyBytes, proto.toByteArray());
  } catch (DBException e) {
    throw new IOException(e);
  }
  return currentEpoch;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:LeveldbRMStateStore.java

示例9: loadRMDTSecretManagerTokenSequenceNumber

import org.iq80.leveldb.DBException; //导入依赖的package包/类
private void loadRMDTSecretManagerTokenSequenceNumber(RMState state)
    throws IOException {
  byte[] data = null;
  try {
    data = db.get(bytes(RM_DT_SEQUENCE_NUMBER_KEY));
  } catch (DBException e) {
    throw new IOException(e);
  }
  if (data != null) {
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
    try {
      state.rmSecretManagerState.dtSequenceNumber = in.readInt();
    } finally {
      IOUtils.cleanup(LOG, in);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:LeveldbRMStateStore.java

示例10: loadAMRMTokenSecretManagerState

import org.iq80.leveldb.DBException; //导入依赖的package包/类
private void loadAMRMTokenSecretManagerState(RMState rmState)
    throws IOException {
  try {
    byte[] data = db.get(bytes(AMRMTOKEN_SECRET_MANAGER_ROOT));
    if (data != null) {
      AMRMTokenSecretManagerStatePBImpl stateData =
          new AMRMTokenSecretManagerStatePBImpl(
              AMRMTokenSecretManagerStateProto.parseFrom(data));
      rmState.amrmTokenSecretManagerState =
          AMRMTokenSecretManagerState.newInstance(
              stateData.getCurrentMasterKey(),
              stateData.getNextMasterKey());
    }
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:LeveldbRMStateStore.java

示例11: removeApplicationStateInternal

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
protected void removeApplicationStateInternal(ApplicationStateData appState)
    throws IOException {
  ApplicationId appId =
      appState.getApplicationSubmissionContext().getApplicationId();
  String appKey = getApplicationNodeKey(appId);
  try {
    WriteBatch batch = db.createWriteBatch();
    try {
      batch.delete(bytes(appKey));
      for (ApplicationAttemptId attemptId : appState.attempts.keySet()) {
        String attemptKey = getApplicationAttemptNodeKey(appKey, attemptId);
        batch.delete(bytes(attemptKey));
      }
      if (LOG.isDebugEnabled()) {
        LOG.debug("Removing state for app " + appId + " and "
            + appState.attempts.size() + " attempts" + " at " + appKey);
      }
      db.write(batch);
    } finally {
      batch.close();
    }
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:LeveldbRMStateStore.java

示例12: storeRMDTMasterKeyState

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@Override
protected void storeRMDTMasterKeyState(DelegationKey masterKey)
    throws IOException {
  String dbKey = getRMDTMasterKeyNodeKey(masterKey);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Storing token master key to " + dbKey);
  }
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  DataOutputStream out = new DataOutputStream(os);
  try {
    masterKey.write(out);
  } finally {
    out.close();
  }
  try {
    db.put(bytes(dbKey), os.toByteArray());
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:LeveldbRMStateStore.java

示例13: loadTokens

import org.iq80.leveldb.DBException; //导入依赖的package包/类
private int loadTokens(TimelineServiceState state) throws IOException {
  byte[] base = KeyBuilder.newInstance().add(TOKEN_ENTRY_PREFIX)
      .getBytesForLookup();
  int numTokens = 0;
  LeveldbIterator iterator = null;
  try {
    for (iterator = new LeveldbIterator(db), iterator.seek(base);
        iterator.hasNext(); iterator.next()) {
      byte[] k = iterator.peekNext().getKey();
      if (!prefixMatches(base, base.length, k)) {
        break;
      }
      byte[] v = iterator.peekNext().getValue();
      loadTokenData(state, v);
      ++numTokens;
    }
  } catch (DBException e) {
    throw new IOException(e);
  } finally {
    IOUtils.cleanup(LOG, iterator);
  }
  return numTokens;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:LeveldbTimelineStateStore.java

示例14: loadLatestSequenceNumber

import org.iq80.leveldb.DBException; //导入依赖的package包/类
private void loadLatestSequenceNumber(TimelineServiceState state)
    throws IOException {
  byte[] data = null;
  try {
    data = db.get(LATEST_SEQUENCE_NUMBER_KEY);
  } catch (DBException e) {
    throw new IOException(e);
  }
  if (data != null) {
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
    try {
      state.latestSequenceNumber = in.readInt();
    } finally {
      IOUtils.cleanup(LOG, in);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:LeveldbTimelineStateStore.java

示例15: loadVersion

import org.iq80.leveldb.DBException; //导入依赖的package包/类
@VisibleForTesting
Version loadVersion() throws IOException {
  try {
    byte[] data = db.get(TIMELINE_STATE_STORE_VERSION_KEY);
    // if version is not stored previously, treat it as CURRENT_VERSION_INFO.
    if (data == null || data.length == 0) {
      return getCurrentVersion();
    }
    Version version =
        new VersionPBImpl(
            YarnServerCommonProtos.VersionProto.parseFrom(data));
    return version;
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:LeveldbTimelineStateStore.java


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