當前位置: 首頁>>代碼示例>>Java>>正文


Java MasterNotRunningException類代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.MasterNotRunningException的典型用法代碼示例。如果您正苦於以下問題:Java MasterNotRunningException類的具體用法?Java MasterNotRunningException怎麽用?Java MasterNotRunningException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MasterNotRunningException類屬於org.apache.hadoop.hbase包,在下文中一共展示了MasterNotRunningException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: moveRegionAndWait

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
private void moveRegionAndWait(HRegionInfo destRegion, ServerName destServer)
    throws InterruptedException, MasterNotRunningException,
    ZooKeeperConnectionException, IOException {
  HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
  TEST_UTIL.getHBaseAdmin().move(
      destRegion.getEncodedNameAsBytes(),
      Bytes.toBytes(destServer.getServerName()));
  while (true) {
    ServerName serverName = master.getAssignmentManager()
        .getRegionStates().getRegionServerOfRegion(destRegion);
    if (serverName != null && serverName.equals(destServer)) {
      TEST_UTIL.assertRegionOnServer(
          destRegion, serverName, 200);
      break;
    }
    Thread.sleep(10);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:TestAdmin1.java

示例2: moveRegionAndWait

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
private void moveRegionAndWait(Region destRegion, HRegionServer destServer)
    throws InterruptedException, MasterNotRunningException,
    ZooKeeperConnectionException, IOException {
  HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
  TEST_UTIL.getHBaseAdmin().move(
      destRegion.getRegionInfo().getEncodedNameAsBytes(),
      Bytes.toBytes(destServer.getServerName().getServerName()));
  while (true) {
    ServerName serverName = master.getAssignmentManager()
      .getRegionStates().getRegionServerOfRegion(destRegion.getRegionInfo());
    if (serverName != null && serverName.equals(destServer.getServerName())) {
      TEST_UTIL.assertRegionOnServer(
        destRegion.getRegionInfo(), serverName, 200);
      break;
    }
    Thread.sleep(10);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:TestWALReplay.java

示例3: assign

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
/**
 * @param regionName
 *          Region name to assign.
 * @throws MasterNotRunningException
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
@Override
public void assign(final byte[] regionName) throws MasterNotRunningException,
    ZooKeeperConnectionException, IOException {
  final byte[] toBeAssigned = getRegionName(regionName);
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      // Hard to know the table name, at least check if meta
      if (isMetaRegion(regionName)) {
        controller.setPriority(TableName.META_TABLE_NAME);
      }

      AssignRegionRequest request =
        RequestConverter.buildAssignRegionRequest(toBeAssigned);
      master.assignRegion(controller,request);
      return null;
    }
  });
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:29,代碼來源:HBaseAdmin.java

示例4: unassign

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
/**
 * Unassign a region from current hosting regionserver.  Region will then be
 * assigned to a regionserver chosen at random.  Region could be reassigned
 * back to the same server.  Use {@link #move(byte[], byte[])} if you want
 * to control the region movement.
 * @param regionName Region to unassign. Will clear any existing RegionPlan
 * if one found.
 * @param force If true, force unassign (Will remove region from
 * regions-in-transition too if present. If results in double assignment
 * use hbck -fix to resolve. To be used by experts).
 * @throws MasterNotRunningException
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
@Override
public void unassign(final byte [] regionName, final boolean force)
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
  final byte[] toBeUnassigned = getRegionName(regionName);
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      // Hard to know the table name, at least check if meta
      if (isMetaRegion(regionName)) {
        controller.setPriority(TableName.META_TABLE_NAME);
      }
      UnassignRegionRequest request =
        RequestConverter.buildUnassignRegionRequest(toBeUnassigned, force);
      master.unassignRegion(controller, request);
      return null;
    }
  });
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:35,代碼來源:HBaseAdmin.java

示例5: checkIfBaseNodeAvailable

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
private void checkIfBaseNodeAvailable(ZooKeeperWatcher zkw)
  throws MasterNotRunningException {
  String errorMsg;
  try {
    if (ZKUtil.checkExists(zkw, zkw.baseZNode) == -1) {
      errorMsg = "The node " + zkw.baseZNode+" is not in ZooKeeper. "
        + "It should have been written by the master. "
        + "Check the value configured in 'zookeeper.znode.parent'. "
        + "There could be a mismatch with the one configured in the master.";
      LOG.error(errorMsg);
      throw new MasterNotRunningException(errorMsg);
    }
  } catch (KeeperException e) {
    errorMsg = "Can't get connection to ZooKeeper: " + e.getMessage();
    LOG.error(errorMsg);
    throw new MasterNotRunningException(errorMsg, e);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:ConnectionManager.java

示例6: HBaseAdminMultiCluster

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
public HBaseAdminMultiCluster(Configuration c)
    throws MasterNotRunningException, ZooKeeperConnectionException,
    IOException {
  super(HBaseMultiClusterConfigUtil.splitMultiConfigFile(c).get(
      HBaseMultiClusterConfigUtil.PRIMARY_NAME));

  Map<String, Configuration> configs = HBaseMultiClusterConfigUtil
      .splitMultiConfigFile(c);

  for (Entry<String, Configuration> entry : configs.entrySet()) {

    if (!entry.getKey().equals(HBaseMultiClusterConfigUtil.PRIMARY_NAME)) {
      HBaseAdmin admin = new HBaseAdmin(entry.getValue());
      LOG.info("creating HBaseAdmin for : " + entry.getKey());
      failoverAdminMap.put(entry.getKey(), admin);
      LOG.info(" - successfully creating HBaseAdmin for : " + entry.getKey());
    }
  }
  LOG.info("Successful loaded all HBaseAdmins");

}
 
開發者ID:cloudera-labs,項目名稱:hbase.mcc,代碼行數:22,代碼來源:HBaseAdminMultiCluster.java

示例7: setBalancerRunning

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
/**
 * Turn the load balancer on or off.
 * @param on If true, enable balancer. If false, disable balancer.
 * @param synchronous If true, it waits until current balance() call, if outstanding, to return.
 * @return Previous balancer value
 */
public boolean setBalancerRunning(final boolean on, final boolean synchronous)
    throws MasterNotRunningException, ZooKeeperConnectionException {
  if (synchronous && synchronousBalanceSwitchSupported) {
    try {
      return getMaster().synchronousBalanceSwitch(on);
    } catch (UndeclaredThrowableException ute) {
      String error = ute.getCause().getMessage();
      if (error != null
          && error.matches("(?s).+NoSuchMethodException:.+synchronousBalanceSwitch.+")) {
        LOG.info("HMaster doesn't support synchronousBalanceSwitch");
        synchronousBalanceSwitchSupported = false;
      } else {
        throw ute;
      }
    }
  }
  return balanceSwitch(on);
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:25,代碼來源:HBaseAdmin.java

示例8: createTable

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
public void createTable(HTableDescriptor hTableDescriptor,
  byte [][] splitKeys)
throws IOException {
  if (!isMasterRunning()) {
    throw new MasterNotRunningException();
  }

  HRegionInfo [] newRegions = getHRegionInfos(hTableDescriptor, splitKeys);
  checkInitialized();
  if (cpHost != null) {
    cpHost.preCreateTable(hTableDescriptor, newRegions);
  }

  this.executorService.submit(new CreateTableHandler(this,
    this.fileSystemManager, this.serverManager, hTableDescriptor, conf,
    newRegions, catalogTracker, assignmentManager));

  if (cpHost != null) {
    cpHost.postCreateTable(hTableDescriptor, newRegions);
  }
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:22,代碼來源:HMaster.java

示例9: main

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException, ParseException {
	String tableName = args[0];
	String fileLocation = args[1];
	
	Configuration conf = HBaseConfiguration.create();
	HTable table = new HTable(conf, tableName);
	
	try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileLocation), "UTF8"))) {
	    String line;
	    while ((line = br.readLine()) != null) {
	       Put put = get_put(line);
	       put.add(Bytes.toBytes("raw"), Bytes.toBytes("line"), Bytes.toBytes(line));
	       table.put(put);
	    }
	}
	table.flushCommits();
	table.close();
}
 
開發者ID:hanhanwu,項目名稱:Hanhan-HBase-MapReduce-in-Java,代碼行數:20,代碼來源:LoadLogs.java

示例10: createTable

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
@Override
public void createTable(HTableDescriptor hTableDescriptor,
                        byte[][] splitKeys) throws IOException {
    if (isStopped()) {
        throw new MasterNotRunningException();
    }

    String namespace = hTableDescriptor.getTableName().getNamespaceAsString();
    ensureNamespaceExists(namespace);

    HRegionInfo[] newRegions = getHRegionInfos(hTableDescriptor, splitKeys);
    checkInitialized();
    sanityCheckTableDescriptor(hTableDescriptor);
    if (cpHost != null) {
        cpHost.preCreateTable(hTableDescriptor, newRegions);
    }
    LOG.info(getClientIdAuditPrefix() + " create " + hTableDescriptor);
    this.service.submit(new CreateTableHandler(this,
            this.fileSystemManager, hTableDescriptor, conf,
            newRegions, this).prepare());
    if (cpHost != null) {
        cpHost.postCreateTable(hTableDescriptor, newRegions);
    }

}
 
開發者ID:grokcoder,項目名稱:pbase,代碼行數:26,代碼來源:HMaster.java

示例11: moveRegionAndWait

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
private void moveRegionAndWait(HRegion destRegion, HRegionServer destServer)
    throws InterruptedException, MasterNotRunningException,
    ZooKeeperConnectionException, IOException {
  HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
  TEST_UTIL.getHBaseAdmin().move(
      destRegion.getRegionInfo().getEncodedNameAsBytes(),
      Bytes.toBytes(destServer.getServerName().getServerName()));
  while (true) {
    ServerName serverName = master.getAssignmentManager()
      .getRegionStates().getRegionServerOfRegion(destRegion.getRegionInfo());
    if (serverName != null && serverName.equals(destServer.getServerName())) {
      TEST_UTIL.assertRegionOnServer(
        destRegion.getRegionInfo(), serverName, 200);
      break;
    }
    Thread.sleep(10);
  }
}
 
開發者ID:grokcoder,項目名稱:pbase,代碼行數:19,代碼來源:TestWALReplay.java

示例12: checkIfBaseNodeAvailable

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
private void checkIfBaseNodeAvailable(ZooKeeperWatcher zkw)
        throws MasterNotRunningException {
    String errorMsg;
    try {
        if (ZKUtil.checkExists(zkw, zkw.baseZNode) == -1) {
            errorMsg = "The node " + zkw.baseZNode + " is not in ZooKeeper. "
                    + "It should have been written by the master. "
                    + "Check the value configured in 'zookeeper.znode.parent'. "
                    + "There could be a mismatch with the one configured in the master.";
            LOG.error(errorMsg);
            throw new MasterNotRunningException(errorMsg);
        }
    } catch (KeeperException e) {
        errorMsg = "Can't get connection to ZooKeeper: " + e.getMessage();
        LOG.error(errorMsg);
        throw new MasterNotRunningException(errorMsg, e);
    }
}
 
開發者ID:grokcoder,項目名稱:pbase,代碼行數:19,代碼來源:ConnectionManager.java

示例13: createTable

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
@Override
public void createTable(HTableDescriptor hTableDescriptor,
  byte [][] splitKeys)
throws IOException {
  if (!isMasterRunning()) {
    throw new MasterNotRunningException();
  }

  String namespace = hTableDescriptor.getTableName().getNamespaceAsString();
  getNamespaceDescriptor(namespace); // ensure namespace exists

  HRegionInfo[] newRegions = getHRegionInfos(hTableDescriptor, splitKeys);
  checkInitialized();
  checkCompression(hTableDescriptor);
  if (cpHost != null) {
    cpHost.preCreateTable(hTableDescriptor, newRegions);
  }
  LOG.info(getClientIdAuditPrefix() + " create " + hTableDescriptor);
  this.executorService.submit(new CreateTableHandler(this,
    this.fileSystemManager, hTableDescriptor, conf,
    newRegions, this).prepare());
  if (cpHost != null) {
    cpHost.postCreateTable(hTableDescriptor, newRegions);
  }

}
 
開發者ID:tenggyut,項目名稱:HIndex,代碼行數:27,代碼來源:HMaster.java

示例14: move

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
/**
 * Move the region <code>r</code> to <code>dest</code>.
 * @param encodedRegionName The encoded region name; i.e. the hash that makes
 * up the region name suffix: e.g. if regionname is
 * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
 * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
 * @param destServerName The servername of the destination regionserver.  If
 * passed the empty byte array we'll assign to a random server.  A server name
 * is made of host, port and startcode.  Here is an example:
 * <code> host187.example.com,60020,1289493121758</code>
 * @throws UnknownRegionException Thrown if we can't find a region named
 * <code>encodedRegionName</code>
 * @throws ZooKeeperConnectionException
 * @throws MasterNotRunningException
 */
public void move(final byte [] encodedRegionName, final byte [] destServerName)
throws HBaseIOException, MasterNotRunningException, ZooKeeperConnectionException {
  MasterKeepAliveConnection stub = connection.getKeepAliveMasterService();
  try {
    MoveRegionRequest request =
      RequestConverter.buildMoveRegionRequest(encodedRegionName, destServerName);
    stub.moveRegion(null,request);
  } catch (ServiceException se) {
    IOException ioe = ProtobufUtil.getRemoteException(se);
    if (ioe instanceof HBaseIOException) {
      throw (HBaseIOException)ioe;
    }
    LOG.error("Unexpected exception: " + se + " from calling HMaster.moveRegion");
  } catch (DeserializationException de) {
    LOG.error("Could not parse destination server name: " + de);
  } finally {
    stub.close();
  }
}
 
開發者ID:tenggyut,項目名稱:HIndex,代碼行數:35,代碼來源:HBaseAdmin.java

示例15: setBalancerRunning

import org.apache.hadoop.hbase.MasterNotRunningException; //導入依賴的package包/類
/**
 * Turn the load balancer on or off.
 * @param on If true, enable balancer. If false, disable balancer.
 * @param synchronous If true, it waits until current balance() call, if outstanding, to return.
 * @return Previous balancer value
 */
public boolean setBalancerRunning(final boolean on, final boolean synchronous)
throws MasterNotRunningException, ZooKeeperConnectionException {
  MasterKeepAliveConnection stub = connection.getKeepAliveMasterService();
  try {
    SetBalancerRunningRequest req =
      RequestConverter.buildSetBalancerRunningRequest(on, synchronous);
    return stub.setBalancerRunning(null, req).getPrevBalanceValue();
  } catch (ServiceException se) {
    IOException ioe = ProtobufUtil.getRemoteException(se);
    if (ioe instanceof MasterNotRunningException) {
      throw (MasterNotRunningException)ioe;
    }
    if (ioe instanceof ZooKeeperConnectionException) {
      throw (ZooKeeperConnectionException)ioe;
    }

    // Throwing MasterNotRunningException even though not really valid in order to not
    // break interface by adding additional exception type.
    throw new MasterNotRunningException("Unexpected exception when calling balanceSwitch",se);
  } finally {
    stub.close();
  }
}
 
開發者ID:tenggyut,項目名稱:HIndex,代碼行數:30,代碼來源:HBaseAdmin.java


注:本文中的org.apache.hadoop.hbase.MasterNotRunningException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。