Java 类org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException 实例源码

项目:ditb    文件:MetaTableLocator.java   
/**
 * Gets the meta region location, if available, and waits for up to the
 * specified timeout if not immediately available.
 * Given the zookeeper notification could be delayed, we will try to
 * get the latest data.
 * @param zkw
 * @param replicaId
 * @param timeout maximum time to wait, in millis
 * @return server name for server hosting meta region formatted as per
 * {@link ServerName}, or null if none available
 * @throws InterruptedException
 * @throws NotAllMetaRegionsOnlineException
 */
public ServerName waitMetaRegionLocation(ZooKeeperWatcher zkw, int replicaId, long timeout)
throws InterruptedException, NotAllMetaRegionsOnlineException {
  try {
    if (ZKUtil.checkExists(zkw, zkw.baseZNode) == -1) {
      String errorMsg = "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 IllegalArgumentException(errorMsg);
    }
  } catch (KeeperException e) {
    throw new IllegalStateException("KeeperException while trying to check baseZNode:", e);
  }
  ServerName sn = blockUntilAvailable(zkw, replicaId, timeout);

  if (sn == null) {
    throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");
  }

  return sn;
}
项目:ditb    文件:MetaTableLocator.java   
/**
 * Waits indefinitely for availability of <code>hbase:meta</code>.  Used during
 * cluster startup.  Does not verify meta, just that something has been
 * set up in zk.
 * @see #waitMetaRegionLocation(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher, long)
 * @throws InterruptedException if interrupted while waiting
 */
public void waitMetaRegionLocation(ZooKeeperWatcher zkw) throws InterruptedException {
  Stopwatch stopwatch = new Stopwatch().start();
  while (!stopped) {
    try {
      if (waitMetaRegionLocation(zkw, 100) != null) break;
      long sleepTime = stopwatch.elapsedMillis();
      // +1 in case sleepTime=0
      if ((sleepTime + 1) % 10000 == 0) {
        LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms");
      }
    } catch (NotAllMetaRegionsOnlineException e) {
      if (LOG.isTraceEnabled()) {
        LOG.trace("hbase:meta still not available, sleeping and retrying." +
          " Reason: " + e.getMessage());
      }
    }
  }
}
项目:LCIndex-HBase-0.94.16    文件:CatalogTracker.java   
/**
 * Gets the current location for <code>.META.</code> if available and waits
 * for up to the specified timeout if not immediately available.  Throws an
 * exception if timed out waiting.  This method differs from {@link #waitForMeta()}
 * in that it will go ahead and verify the location gotten from ZooKeeper and
 * -ROOT- region by trying to use returned connection.
 * @param timeout maximum time to wait for meta availability, in milliseconds
 * @return {@link ServerName} for server hosting <code>.META.</code> or null
 * if none available
 * @throws InterruptedException if interrupted while waiting
 * @throws IOException unexpected exception connecting to meta server
 * @throws NotAllMetaRegionsOnlineException if meta not available before
 * timeout
 */
public ServerName waitForMeta(long timeout)
throws InterruptedException, IOException, NotAllMetaRegionsOnlineException {
  long stop = timeout == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + timeout;
  long waitTime = Math.min(50, timeout);
  synchronized (metaAvailable) {
    while(!stopped && System.currentTimeMillis() < stop) {
      if (getMetaServerConnection() != null) {
        return metaLocation;
      }
      // perhaps -ROOT- region isn't available, let us wait a bit and retry.
      metaAvailable.wait(waitTime);
    }
    if (getMetaServerConnection() == null) {
      throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
    }
    return metaLocation;
  }
}
项目:LCIndex-HBase-0.94.16    文件:MetaEditor.java   
/**
 * Offline parent in meta.
 * Used when splitting.
 * @param catalogTracker
 * @param parent
 * @param a Split daughter region A
 * @param b Split daughter region B
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
public static void offlineParentInMeta(CatalogTracker catalogTracker,
    HRegionInfo parent, final HRegionInfo a, final HRegionInfo b)
throws NotAllMetaRegionsOnlineException, IOException {
  HRegionInfo copyOfParent = new HRegionInfo(parent);
  copyOfParent.setOffline(true);
  copyOfParent.setSplit(true);
  Put put = new Put(copyOfParent.getRegionName());
  addRegionInfo(put, copyOfParent);
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER,
    Writables.getBytes(a));
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER,
    Writables.getBytes(b));
  putToMetaTable(catalogTracker, put);
  LOG.info("Offlined parent region " + parent.getRegionNameAsString() +
    " in META");
}
项目:LCIndex-HBase-0.94.16    文件:CloneSnapshotHandler.java   
public CloneSnapshotHandler(final MasterServices masterServices,
    final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor,
    final MasterMetrics metricsMaster)
    throws NotAllMetaRegionsOnlineException, TableExistsException, IOException {
  super(masterServices, masterServices.getMasterFileSystem(),
    masterServices.getServerManager(), hTableDescriptor,
    masterServices.getConfiguration(), null, masterServices.getCatalogTracker(),
    masterServices.getAssignmentManager());
  this.metricsMaster = metricsMaster;

  // Snapshot information
  this.snapshot = snapshot;

  // Monitor
  this.monitor = new ForeignExceptionDispatcher();
  this.status = TaskMonitor.get().createStatus("Cloning  snapshot '" + snapshot.getName() +
    "' to table " + hTableDescriptor.getNameAsString());
}
项目:LCIndex-HBase-0.94.16    文件:TestCatalogJanitor.java   
MockServer(final HBaseTestingUtility htu)
throws NotAllMetaRegionsOnlineException, IOException, InterruptedException {
  this.c = htu.getConfiguration();
  // Mock an HConnection and a HRegionInterface implementation.  Have the
  // HConnection return the HRI.  Have the HRI return a few mocked up responses
  // to make our test work.
  this.connection =
    HConnectionTestingUtility.getMockedConnectionAndDecorate(this.c,
      Mockito.mock(HRegionInterface.class),
      new ServerName("example.org,12345,6789"),
      HRegionInfo.FIRST_META_REGIONINFO);
  // Set hbase.rootdir into test dir.
  FileSystem fs = FileSystem.get(this.c);
  Path rootdir = fs.makeQualified(new Path(this.c.get(HConstants.HBASE_DIR)));
  this.c.set(HConstants.HBASE_DIR, rootdir.toString());
  this.ct = Mockito.mock(CatalogTracker.class);
  HRegionInterface hri = Mockito.mock(HRegionInterface.class);
  Mockito.when(this.ct.getConnection()).thenReturn(this.connection);
  Mockito.when(ct.waitForMetaServerConnection(Mockito.anyLong())).thenReturn(hri);
}
项目:pbase    文件:MetaTableLocator.java   
/**
 * Gets the meta region location, if available, and waits for up to the
 * specified timeout if not immediately available.
 * Given the zookeeper notification could be delayed, we will try to
 * get the latest data.
 * @param timeout maximum time to wait, in millis
 * @return server name for server hosting meta region formatted as per
 * {@link ServerName}, or null if none available
 * @throws InterruptedException if interrupted while waiting
 */
public ServerName waitMetaRegionLocation(ZooKeeperWatcher zkw, long timeout)
throws InterruptedException, NotAllMetaRegionsOnlineException {
  try {
    if (ZKUtil.checkExists(zkw, zkw.baseZNode) == -1) {
      String errorMsg = "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 IllegalArgumentException(errorMsg);
    }
  } catch (KeeperException e) {
    throw new IllegalStateException("KeeperException while trying to check baseZNode:", e);
  }
  ServerName sn = blockUntilAvailable(zkw, timeout);

  if (sn == null) {
    throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");
  }

  return sn;
}
项目:pbase    文件:MetaTableLocator.java   
/**
 * Waits indefinitely for availability of <code>hbase:meta</code>.  Used during
 * cluster startup.  Does not verify meta, just that something has been
 * set up in zk.
 * @see #waitMetaRegionLocation(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher, long)
 * @throws InterruptedException if interrupted while waiting
 */
public void waitMetaRegionLocation(ZooKeeperWatcher zkw) throws InterruptedException {
  Stopwatch stopwatch = new Stopwatch().start();
  while (!stopped) {
    try {
      if (waitMetaRegionLocation(zkw, 100) != null) break;
      long sleepTime = stopwatch.elapsedMillis();
      // +1 in case sleepTime=0
      if ((sleepTime + 1) % 10000 == 0) {
        LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms");
      }
    } catch (NotAllMetaRegionsOnlineException e) {
      if (LOG.isTraceEnabled()) {
        LOG.trace("hbase:meta still not available, sleeping and retrying." +
          " Reason: " + e.getMessage());
      }
    }
  }
}
项目:HIndex    文件:CatalogTracker.java   
/**
 * Waits indefinitely for availability of <code>hbase:meta</code>.  Used during
 * cluster startup.  Does not verify meta, just that something has been
 * set up in zk.
 * @see #waitForMeta(long)
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForMeta() throws InterruptedException {
  Stopwatch stopwatch = new Stopwatch().start();
  while (!this.stopped) {
    try {
      if (waitForMeta(100) != null) break;
      long sleepTime = stopwatch.elapsedMillis();
      // +1 in case sleepTime=0
      if ((sleepTime + 1) % 10000 == 0) {
        LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms");
      }
    } catch (NotAllMetaRegionsOnlineException e) {
      if (LOG.isTraceEnabled()) {
        LOG.trace("hbase:meta still not available, sleeping and retrying." +
        " Reason: " + e.getMessage());
      }
    }
  }
}
项目:armeria    文件:HBaseClientCompatibilityTest.java   
/**
 * Ensure Armeria's dependencies do not cause a trouble with hbase-shaded-client.
 *
 * @see <a href="https://issues.apache.org/jira/browse/HBASE-14963">HBASE-14963</a>
 */
@Test(expected = NotAllMetaRegionsOnlineException.class)
public void testGuavaConflict() throws Exception {
    // Make sure Armeria is available in the class path.
    assertThat(Version.identify(Server.class.getClassLoader())).isNotNull();
    // Make sure newer Guava is available in the class path.
    assertThat(Stopwatch.class.getDeclaredConstructor().getModifiers()).is(new Condition<>(
            value -> !Modifier.isPublic(value),
            "Recent Guava Stopwatch should have non-public default constructor."));

    final MetaTableLocator locator = new MetaTableLocator();
    final ZooKeeperWatcher zkw = mock(ZooKeeperWatcher.class);
    final RecoverableZooKeeper zk = mock(RecoverableZooKeeper.class);
    when(zkw.getRecoverableZooKeeper()).thenReturn(zk);
    when(zk.exists(any(), any())).thenReturn(new Stat(0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0));

    locator.waitMetaRegionLocation(zkw, 100);
}
项目:IRIndex    文件:CatalogTracker.java   
/**
 * Gets the current location for <code>.META.</code> if available and waits
 * for up to the specified timeout if not immediately available.  Throws an
 * exception if timed out waiting.  This method differs from {@link #waitForMeta()}
 * in that it will go ahead and verify the location gotten from ZooKeeper and
 * -ROOT- region by trying to use returned connection.
 * @param timeout maximum time to wait for meta availability, in milliseconds
 * @return {@link ServerName} for server hosting <code>.META.</code> or null
 * if none available
 * @throws InterruptedException if interrupted while waiting
 * @throws IOException unexpected exception connecting to meta server
 * @throws NotAllMetaRegionsOnlineException if meta not available before
 * timeout
 */
public ServerName waitForMeta(long timeout)
throws InterruptedException, IOException, NotAllMetaRegionsOnlineException {
  long stop = timeout == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + timeout;
  long waitTime = Math.min(50, timeout);
  synchronized (metaAvailable) {
    while(!stopped && System.currentTimeMillis() < stop) {
      if (getMetaServerConnection() != null) {
        return metaLocation;
      }
      // perhaps -ROOT- region isn't available, let us wait a bit and retry.
      metaAvailable.wait(waitTime);
    }
    if (getMetaServerConnection() == null) {
      throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
    }
    return metaLocation;
  }
}
项目:IRIndex    文件:MetaEditor.java   
/**
 * Offline parent in meta.
 * Used when splitting.
 * @param catalogTracker
 * @param parent
 * @param a Split daughter region A
 * @param b Split daughter region B
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
public static void offlineParentInMeta(CatalogTracker catalogTracker,
    HRegionInfo parent, final HRegionInfo a, final HRegionInfo b)
throws NotAllMetaRegionsOnlineException, IOException {
  HRegionInfo copyOfParent = new HRegionInfo(parent);
  copyOfParent.setOffline(true);
  copyOfParent.setSplit(true);
  Put put = new Put(copyOfParent.getRegionName());
  addRegionInfo(put, copyOfParent);
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER,
    Writables.getBytes(a));
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER,
    Writables.getBytes(b));
  putToMetaTable(catalogTracker, put);
  LOG.info("Offlined parent region " + parent.getRegionNameAsString() +
    " in META");
}
项目:IRIndex    文件:CloneSnapshotHandler.java   
public CloneSnapshotHandler(final MasterServices masterServices,
    final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor,
    final MasterMetrics metricsMaster)
    throws NotAllMetaRegionsOnlineException, TableExistsException, IOException {
  super(masterServices, masterServices.getMasterFileSystem(),
    masterServices.getServerManager(), hTableDescriptor,
    masterServices.getConfiguration(), null, masterServices.getCatalogTracker(),
    masterServices.getAssignmentManager());
  this.metricsMaster = metricsMaster;

  // Snapshot information
  this.snapshot = snapshot;

  // Monitor
  this.monitor = new ForeignExceptionDispatcher();
  this.status = TaskMonitor.get().createStatus("Cloning  snapshot '" + snapshot.getName() +
    "' to table " + hTableDescriptor.getNameAsString());
}
项目:IRIndex    文件:TestCatalogJanitor.java   
MockServer(final HBaseTestingUtility htu)
throws NotAllMetaRegionsOnlineException, IOException, InterruptedException {
  this.c = htu.getConfiguration();
  // Mock an HConnection and a HRegionInterface implementation.  Have the
  // HConnection return the HRI.  Have the HRI return a few mocked up responses
  // to make our test work.
  this.connection =
    HConnectionTestingUtility.getMockedConnectionAndDecorate(this.c,
      Mockito.mock(HRegionInterface.class),
      new ServerName("example.org,12345,6789"),
      HRegionInfo.FIRST_META_REGIONINFO);
  // Set hbase.rootdir into test dir.
  FileSystem fs = FileSystem.get(this.c);
  Path rootdir = fs.makeQualified(new Path(this.c.get(HConstants.HBASE_DIR)));
  this.c.set(HConstants.HBASE_DIR, rootdir.toString());
  this.ct = Mockito.mock(CatalogTracker.class);
  HRegionInterface hri = Mockito.mock(HRegionInterface.class);
  Mockito.when(this.ct.getConnection()).thenReturn(this.connection);
  Mockito.when(ct.waitForMetaServerConnection(Mockito.anyLong())).thenReturn(hri);
}
项目:hbase    文件:MetaTableLocator.java   
/**
 * Gets the meta region location, if available, and waits for up to the specified timeout if not
 * immediately available. Given the zookeeper notification could be delayed, we will try to
 * get the latest data.
 *
 * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation
 * @param replicaId the ID of the replica
 * @param timeout maximum time to wait, in millis
 * @return server name for server hosting meta region formatted as per
 * {@link ServerName}, or null if none available
 * @throws InterruptedException if waiting for the socket operation fails
 * @throws NotAllMetaRegionsOnlineException if a meta or root region is not online
 */
public ServerName waitMetaRegionLocation(ZKWatcher zkw, int replicaId, long timeout)
throws InterruptedException, NotAllMetaRegionsOnlineException {
  try {
    if (ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) == -1) {
      String errorMsg = "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 IllegalArgumentException(errorMsg);
    }
  } catch (KeeperException e) {
    throw new IllegalStateException("KeeperException while trying to check baseZNode:", e);
  }
  ServerName sn = blockUntilAvailable(zkw, replicaId, timeout);

  if (sn == null) {
    throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");
  }

  return sn;
}
项目:hbase    文件:MetaTableLocator.java   
/**
 * Waits indefinitely for availability of <code>hbase:meta</code>.  Used during
 * cluster startup.  Does not verify meta, just that something has been
 * set up in zk.
 * @see #waitMetaRegionLocation(ZKWatcher, long)
 * @throws InterruptedException if interrupted while waiting
 */
public void waitMetaRegionLocation(ZKWatcher zkw) throws InterruptedException {
  long startTime = System.currentTimeMillis();
  while (!stopped) {
    try {
      if (waitMetaRegionLocation(zkw, 100) != null) {
        break;
      }

      long sleepTime = System.currentTimeMillis() - startTime;
      // +1 in case sleepTime=0
      if ((sleepTime + 1) % 10000 == 0) {
        LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms");
      }
    } catch (NotAllMetaRegionsOnlineException e) {
      if (LOG.isTraceEnabled()) {
        LOG.trace("hbase:meta still not available, sleeping and retrying." +
          " Reason: " + e.getMessage());
      }
    }
  }
}
项目:RStore    文件:CatalogTracker.java   
/**
 * Gets the current location for <code>.META.</code> if available and waits
 * for up to the specified timeout if not immediately available.  Throws an
 * exception if timed out waiting.  This method differs from {@link #waitForMeta()}
 * in that it will go ahead and verify the location gotten from ZooKeeper and
 * -ROOT- region by trying to use returned connection.
 * @param timeout maximum time to wait for meta availability, in milliseconds
 * @return {@link ServerName} for server hosting <code>.META.</code> or null
 * if none available
 * @throws InterruptedException if interrupted while waiting
 * @throws IOException unexpected exception connecting to meta server
 * @throws NotAllMetaRegionsOnlineException if meta not available before
 * timeout
 */
public ServerName waitForMeta(long timeout)
throws InterruptedException, IOException, NotAllMetaRegionsOnlineException {
  long stop = System.currentTimeMillis() + timeout;
  long waitTime = Math.min(50, timeout);
  synchronized (metaAvailable) {
    while(!stopped && (timeout == 0 || System.currentTimeMillis() < stop)) {
      if (getMetaServerConnection() != null) {
        return metaLocation;
      }
      // perhaps -ROOT- region isn't available, let us wait a bit and retry.
      metaAvailable.wait(waitTime);
    }
    if (getMetaServerConnection() == null) {
      throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
    }
    return metaLocation;
  }
}
项目:RStore    文件:MetaEditor.java   
/**
 * Offline parent in meta.
 * Used when splitting.
 * @param catalogTracker
 * @param parent
 * @param a Split daughter region A
 * @param b Split daughter region B
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
public static void offlineParentInMeta(CatalogTracker catalogTracker,
    HRegionInfo parent, final HRegionInfo a, final HRegionInfo b)
throws NotAllMetaRegionsOnlineException, IOException {
  HRegionInfo copyOfParent = new HRegionInfo(parent);
  copyOfParent.setOffline(true);
  copyOfParent.setSplit(true);
  Put put = new Put(copyOfParent.getRegionName());
  addRegionInfo(put, copyOfParent);
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER,
    Writables.getBytes(a));
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER,
    Writables.getBytes(b));
  putToMetaTable(catalogTracker, put);
  LOG.info("Offlined parent region " + parent.getRegionNameAsString() +
    " in META");
}
项目:PyroDB    文件:CatalogTracker.java   
/**
 * Waits indefinitely for availability of <code>hbase:meta</code>.  Used during
 * cluster startup.  Does not verify meta, just that something has been
 * set up in zk.
 * @see #waitForMeta(long)
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForMeta() throws InterruptedException {
  Stopwatch stopwatch = new Stopwatch().start();
  while (!this.stopped) {
    try {
      if (waitForMeta(100) != null) break;
      long sleepTime = stopwatch.elapsedMillis();
      // +1 in case sleepTime=0
      if ((sleepTime + 1) % 10000 == 0) {
        LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms");
      }
    } catch (NotAllMetaRegionsOnlineException e) {
      if (LOG.isTraceEnabled()) {
        LOG.trace("hbase:meta still not available, sleeping and retrying." +
        " Reason: " + e.getMessage());
      }
    }
  }
}
项目:HBase-Research    文件:CatalogTracker.java   
/**
 * Gets the current location for <code>.META.</code> if available and waits
 * for up to the specified timeout if not immediately available.  Throws an
 * exception if timed out waiting.  This method differs from {@link #waitForMeta()}
 * in that it will go ahead and verify the location gotten from ZooKeeper and
 * -ROOT- region by trying to use returned connection.
 * @param timeout maximum time to wait for meta availability, in milliseconds
 * @return {@link ServerName} for server hosting <code>.META.</code> or null
 * if none available
 * @throws InterruptedException if interrupted while waiting
 * @throws IOException unexpected exception connecting to meta server
 * @throws NotAllMetaRegionsOnlineException if meta not available before
 * timeout
 */
public ServerName waitForMeta(long timeout)
throws InterruptedException, IOException, NotAllMetaRegionsOnlineException {
  long stop = timeout == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + timeout;
  long waitTime = Math.min(50, timeout);
  synchronized (metaAvailable) {
    while(!stopped && System.currentTimeMillis() < stop) {
      if (getMetaServerConnection() != null) {
        return metaLocation;
      }
      // perhaps -ROOT- region isn't available, let us wait a bit and retry.
      metaAvailable.wait(waitTime);
    }
    if (getMetaServerConnection() == null) {
      throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
    }
    return metaLocation;
  }
}
项目:HBase-Research    文件:MetaEditor.java   
/**
 * Offline parent in meta.
 * Used when splitting.
 * @param catalogTracker
 * @param parent
 * @param a Split daughter region A
 * @param b Split daughter region B
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
public static void offlineParentInMeta(CatalogTracker catalogTracker,
    HRegionInfo parent, final HRegionInfo a, final HRegionInfo b)
throws NotAllMetaRegionsOnlineException, IOException {
  HRegionInfo copyOfParent = new HRegionInfo(parent);
  copyOfParent.setOffline(true);
  copyOfParent.setSplit(true);
  Put put = new Put(copyOfParent.getRegionName());
  addRegionInfo(put, copyOfParent);
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER,
    Writables.getBytes(a));
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER,
    Writables.getBytes(b));
  putToMetaTable(catalogTracker, put);
  LOG.info("Offlined parent region " + parent.getRegionNameAsString() +
    " in META");
}
项目:HBase-Research    文件:CloneSnapshotHandler.java   
public CloneSnapshotHandler(final MasterServices masterServices,
    final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor,
    final MasterMetrics metricsMaster)
    throws NotAllMetaRegionsOnlineException, TableExistsException, IOException {
  super(masterServices, masterServices.getMasterFileSystem(),
    masterServices.getServerManager(), hTableDescriptor,
    masterServices.getConfiguration(), null, masterServices.getCatalogTracker(),
    masterServices.getAssignmentManager());
  this.metricsMaster = metricsMaster;

  // Snapshot information
  this.snapshot = snapshot;

  // Monitor
  this.monitor = new ForeignExceptionDispatcher();
  this.status = TaskMonitor.get().createStatus("Cloning  snapshot '" + snapshot.getName() +
    "' to table " + hTableDescriptor.getNameAsString());
}
项目:HBase-Research    文件:TestCatalogJanitor.java   
MockServer(final HBaseTestingUtility htu)
throws NotAllMetaRegionsOnlineException, IOException, InterruptedException {
  this.c = htu.getConfiguration();
  // Mock an HConnection and a HRegionInterface implementation.  Have the
  // HConnection return the HRI.  Have the HRI return a few mocked up responses
  // to make our test work.
  this.connection =
    HConnectionTestingUtility.getMockedConnectionAndDecorate(this.c,
      Mockito.mock(HRegionInterface.class),
      new ServerName("example.org,12345,6789"),
      HRegionInfo.FIRST_META_REGIONINFO);
  // Set hbase.rootdir into test dir.
  FileSystem fs = FileSystem.get(this.c);
  Path rootdir = fs.makeQualified(new Path(this.c.get(HConstants.HBASE_DIR)));
  this.c.set(HConstants.HBASE_DIR, rootdir.toString());
  this.ct = Mockito.mock(CatalogTracker.class);
  HRegionInterface hri = Mockito.mock(HRegionInterface.class);
  Mockito.when(this.ct.getConnection()).thenReturn(this.connection);
  Mockito.when(ct.waitForMetaServerConnection(Mockito.anyLong())).thenReturn(hri);
}
项目:hbase-0.94.8-qod    文件:CatalogTracker.java   
/**
 * Gets the current location for <code>.META.</code> if available and waits
 * for up to the specified timeout if not immediately available.  Throws an
 * exception if timed out waiting.  This method differs from {@link #waitForMeta()}
 * in that it will go ahead and verify the location gotten from ZooKeeper and
 * -ROOT- region by trying to use returned connection.
 * @param timeout maximum time to wait for meta availability, in milliseconds
 * @return {@link ServerName} for server hosting <code>.META.</code> or null
 * if none available
 * @throws InterruptedException if interrupted while waiting
 * @throws IOException unexpected exception connecting to meta server
 * @throws NotAllMetaRegionsOnlineException if meta not available before
 * timeout
 */
public ServerName waitForMeta(long timeout)
throws InterruptedException, IOException, NotAllMetaRegionsOnlineException {
  long stop = timeout == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + timeout;
  long waitTime = Math.min(50, timeout);
  synchronized (metaAvailable) {
    while(!stopped && System.currentTimeMillis() < stop) {
      if (getMetaServerConnection() != null) {
        return metaLocation;
      }
      // perhaps -ROOT- region isn't available, let us wait a bit and retry.
      metaAvailable.wait(waitTime);
    }
    if (getMetaServerConnection() == null) {
      throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
    }
    return metaLocation;
  }
}
项目:hbase-0.94.8-qod    文件:MetaEditor.java   
/**
 * Offline parent in meta.
 * Used when splitting.
 * @param catalogTracker
 * @param parent
 * @param a Split daughter region A
 * @param b Split daughter region B
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
public static void offlineParentInMeta(CatalogTracker catalogTracker,
    HRegionInfo parent, final HRegionInfo a, final HRegionInfo b)
throws NotAllMetaRegionsOnlineException, IOException {
  HRegionInfo copyOfParent = new HRegionInfo(parent);
  copyOfParent.setOffline(true);
  copyOfParent.setSplit(true);
  Put put = new Put(copyOfParent.getRegionName());
  addRegionInfo(put, copyOfParent);
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER,
    Writables.getBytes(a));
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER,
    Writables.getBytes(b));
  putToMetaTable(catalogTracker, put);
  LOG.info("Offlined parent region " + parent.getRegionNameAsString() +
    " in META");
}
项目:hbase-0.94.8-qod    文件:CloneSnapshotHandler.java   
public CloneSnapshotHandler(final MasterServices masterServices,
    final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor,
    final MasterMetrics metricsMaster)
    throws NotAllMetaRegionsOnlineException, TableExistsException, IOException {
  super(masterServices, masterServices.getMasterFileSystem(),
    masterServices.getServerManager(), hTableDescriptor,
    masterServices.getConfiguration(), null, masterServices.getCatalogTracker(),
    masterServices.getAssignmentManager());
  this.metricsMaster = metricsMaster;

  // Snapshot information
  this.snapshot = snapshot;

  // Monitor
  this.monitor = new ForeignExceptionDispatcher();
  this.status = TaskMonitor.get().createStatus("Cloning  snapshot '" + snapshot.getName() +
    "' to table " + hTableDescriptor.getNameAsString());
}
项目:hbase-0.94.8-qod    文件:TestCatalogJanitor.java   
MockServer(final HBaseTestingUtility htu)
throws NotAllMetaRegionsOnlineException, IOException, InterruptedException {
  this.c = htu.getConfiguration();
  // Mock an HConnection and a HRegionInterface implementation.  Have the
  // HConnection return the HRI.  Have the HRI return a few mocked up responses
  // to make our test work.
  this.connection =
    HConnectionTestingUtility.getMockedConnectionAndDecorate(this.c,
      Mockito.mock(HRegionInterface.class),
      new ServerName("example.org,12345,6789"),
      HRegionInfo.FIRST_META_REGIONINFO);
  // Set hbase.rootdir into test dir.
  FileSystem fs = FileSystem.get(this.c);
  Path rootdir = fs.makeQualified(new Path(this.c.get(HConstants.HBASE_DIR)));
  this.c.set(HConstants.HBASE_DIR, rootdir.toString());
  this.ct = Mockito.mock(CatalogTracker.class);
  HRegionInterface hri = Mockito.mock(HRegionInterface.class);
  Mockito.when(this.ct.getConnection()).thenReturn(this.connection);
  Mockito.when(ct.waitForMetaServerConnection(Mockito.anyLong())).thenReturn(hri);
}
项目:hbase-0.94.8-qod    文件:CatalogTracker.java   
/**
 * Gets the current location for <code>.META.</code> if available and waits
 * for up to the specified timeout if not immediately available.  Throws an
 * exception if timed out waiting.  This method differs from {@link #waitForMeta()}
 * in that it will go ahead and verify the location gotten from ZooKeeper and
 * -ROOT- region by trying to use returned connection.
 * @param timeout maximum time to wait for meta availability, in milliseconds
 * @return {@link ServerName} for server hosting <code>.META.</code> or null
 * if none available
 * @throws InterruptedException if interrupted while waiting
 * @throws IOException unexpected exception connecting to meta server
 * @throws NotAllMetaRegionsOnlineException if meta not available before
 * timeout
 */
public ServerName waitForMeta(long timeout)
throws InterruptedException, IOException, NotAllMetaRegionsOnlineException {
  long stop = timeout == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + timeout;
  long waitTime = Math.min(50, timeout);
  synchronized (metaAvailable) {
    while(!stopped && System.currentTimeMillis() < stop) {
      if (getMetaServerConnection() != null) {
        return metaLocation;
      }
      // perhaps -ROOT- region isn't available, let us wait a bit and retry.
      metaAvailable.wait(waitTime);
    }
    if (getMetaServerConnection() == null) {
      throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
    }
    return metaLocation;
  }
}
项目:hbase-0.94.8-qod    文件:MetaEditor.java   
/**
 * Offline parent in meta.
 * Used when splitting.
 * @param catalogTracker
 * @param parent
 * @param a Split daughter region A
 * @param b Split daughter region B
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
public static void offlineParentInMeta(CatalogTracker catalogTracker,
    HRegionInfo parent, final HRegionInfo a, final HRegionInfo b)
throws NotAllMetaRegionsOnlineException, IOException {
  HRegionInfo copyOfParent = new HRegionInfo(parent);
  copyOfParent.setOffline(true);
  copyOfParent.setSplit(true);
  Put put = new Put(copyOfParent.getRegionName());
  addRegionInfo(put, copyOfParent);
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER,
    Writables.getBytes(a));
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER,
    Writables.getBytes(b));
  putToMetaTable(catalogTracker, put);
  LOG.info("Offlined parent region " + parent.getRegionNameAsString() +
    " in META");
}
项目:hbase-0.94.8-qod    文件:CloneSnapshotHandler.java   
public CloneSnapshotHandler(final MasterServices masterServices,
    final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor,
    final MasterMetrics metricsMaster)
    throws NotAllMetaRegionsOnlineException, TableExistsException, IOException {
  super(masterServices, masterServices.getMasterFileSystem(),
    masterServices.getServerManager(), hTableDescriptor,
    masterServices.getConfiguration(), null, masterServices.getCatalogTracker(),
    masterServices.getAssignmentManager());
  this.metricsMaster = metricsMaster;

  // Snapshot information
  this.snapshot = snapshot;

  // Monitor
  this.monitor = new ForeignExceptionDispatcher();
  this.status = TaskMonitor.get().createStatus("Cloning  snapshot '" + snapshot.getName() +
    "' to table " + hTableDescriptor.getNameAsString());
}
项目:hbase-0.94.8-qod    文件:TestCatalogJanitor.java   
MockServer(final HBaseTestingUtility htu)
throws NotAllMetaRegionsOnlineException, IOException, InterruptedException {
  this.c = htu.getConfiguration();
  // Mock an HConnection and a HRegionInterface implementation.  Have the
  // HConnection return the HRI.  Have the HRI return a few mocked up responses
  // to make our test work.
  this.connection =
    HConnectionTestingUtility.getMockedConnectionAndDecorate(this.c,
      Mockito.mock(HRegionInterface.class),
      new ServerName("example.org,12345,6789"),
      HRegionInfo.FIRST_META_REGIONINFO);
  // Set hbase.rootdir into test dir.
  FileSystem fs = FileSystem.get(this.c);
  Path rootdir = fs.makeQualified(new Path(this.c.get(HConstants.HBASE_DIR)));
  this.c.set(HConstants.HBASE_DIR, rootdir.toString());
  this.ct = Mockito.mock(CatalogTracker.class);
  HRegionInterface hri = Mockito.mock(HRegionInterface.class);
  Mockito.when(this.ct.getConnection()).thenReturn(this.connection);
  Mockito.when(ct.waitForMetaServerConnection(Mockito.anyLong())).thenReturn(hri);
}
项目:DominoHBase    文件:CatalogTracker.java   
/**
 * Gets the current location for <code>.META.</code> if available and waits
 * for up to the specified timeout if not immediately available.  Throws an
 * exception if timed out waiting.  This method differs from {@link #waitForMeta()}
 * in that it will go ahead and verify the location gotten from ZooKeeper and
 * -ROOT- region by trying to use returned connection.
 * @param timeout maximum time to wait for meta availability, in milliseconds
 * @return {@link ServerName} for server hosting <code>.META.</code> or null
 * if none available
 * @throws InterruptedException if interrupted while waiting
 * @throws IOException unexpected exception connecting to meta server
 * @throws NotAllMetaRegionsOnlineException if meta not available before
 * timeout
 */
public ServerName waitForMeta(long timeout)
throws InterruptedException, IOException, NotAllMetaRegionsOnlineException {
  long stop = System.currentTimeMillis() + timeout;
  long waitTime = Math.min(50, timeout);
  synchronized (metaAvailable) {
    while(!stopped && (timeout == 0 || System.currentTimeMillis() < stop)) {
      if (getMetaServerConnection() != null) {
        return metaLocation;
      }
      // perhaps -ROOT- region isn't available, let us wait a bit and retry.
      metaAvailable.wait(waitTime);
    }
    if (getMetaServerConnection() == null) {
      throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
    }
    return metaLocation;
  }
}
项目:DominoHBase    文件:MetaEditor.java   
/**
 * Offline parent in meta.
 * Used when splitting.
 * @param catalogTracker
 * @param parent
 * @param a Split daughter region A
 * @param b Split daughter region B
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
public static void offlineParentInMeta(CatalogTracker catalogTracker,
    HRegionInfo parent, final HRegionInfo a, final HRegionInfo b)
throws NotAllMetaRegionsOnlineException, IOException {
  HRegionInfo copyOfParent = new HRegionInfo(parent);
  copyOfParent.setOffline(true);
  copyOfParent.setSplit(true);
  HTable meta = MetaReader.getMetaHTable(catalogTracker);
  try {
    addRegionToMeta(meta, copyOfParent, a, b);
    LOG.info("Offlined parent region " + parent.getRegionNameAsString() +
        " in META");
  } finally {
    meta.close();
  }
}
项目:hindex    文件:CatalogTracker.java   
/**
 * Gets the current location for <code>.META.</code> if available and waits
 * for up to the specified timeout if not immediately available.  Throws an
 * exception if timed out waiting.  This method differs from {@link #waitForMeta()}
 * in that it will go ahead and verify the location gotten from ZooKeeper and
 * -ROOT- region by trying to use returned connection.
 * @param timeout maximum time to wait for meta availability, in milliseconds
 * @return {@link ServerName} for server hosting <code>.META.</code> or null
 * if none available
 * @throws InterruptedException if interrupted while waiting
 * @throws IOException unexpected exception connecting to meta server
 * @throws NotAllMetaRegionsOnlineException if meta not available before
 * timeout
 */
public ServerName waitForMeta(long timeout)
throws InterruptedException, IOException, NotAllMetaRegionsOnlineException {
  long stop = timeout == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + timeout;
  long waitTime = Math.min(50, timeout);
  synchronized (metaAvailable) {
    while(!stopped && System.currentTimeMillis() < stop) {
      if (getMetaServerConnection() != null) {
        return metaLocation;
      }
      // perhaps -ROOT- region isn't available, let us wait a bit and retry.
      metaAvailable.wait(waitTime);
    }
    if (getMetaServerConnection() == null) {
      throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
    }
    return metaLocation;
  }
}
项目:hindex    文件:MetaEditor.java   
/**
 * Offline parent in meta.
 * Used when splitting.
 * @param catalogTracker
 * @param parent
 * @param a Split daughter region A
 * @param b Split daughter region B
 * @throws NotAllMetaRegionsOnlineException
 * @throws IOException
 */
public static void offlineParentInMeta(CatalogTracker catalogTracker,
    HRegionInfo parent, final HRegionInfo a, final HRegionInfo b)
throws NotAllMetaRegionsOnlineException, IOException {
  HRegionInfo copyOfParent = new HRegionInfo(parent);
  copyOfParent.setOffline(true);
  copyOfParent.setSplit(true);
  Put put = new Put(copyOfParent.getRegionName());
  addRegionInfo(put, copyOfParent);
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER,
    Writables.getBytes(a));
  put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER,
    Writables.getBytes(b));
  putToMetaTable(catalogTracker, put);
  LOG.info("Offlined parent region " + parent.getRegionNameAsString() +
    " in META");
}
项目:hindex    文件:CloneSnapshotHandler.java   
public CloneSnapshotHandler(final MasterServices masterServices,
    final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor,
    final MasterMetrics metricsMaster)
    throws NotAllMetaRegionsOnlineException, TableExistsException, IOException {
  super(masterServices, masterServices.getMasterFileSystem(),
    masterServices.getServerManager(), hTableDescriptor,
    masterServices.getConfiguration(), null, masterServices.getCatalogTracker(),
    masterServices.getAssignmentManager());
  this.metricsMaster = metricsMaster;

  // Snapshot information
  this.snapshot = snapshot;

  // Monitor
  this.monitor = new ForeignExceptionDispatcher();
  this.status = TaskMonitor.get().createStatus("Cloning  snapshot '" + snapshot.getName() +
    "' to table " + hTableDescriptor.getNameAsString());
}
项目:hindex    文件:TestCatalogJanitor.java   
MockServer(final HBaseTestingUtility htu)
throws NotAllMetaRegionsOnlineException, IOException, InterruptedException {
  this.c = htu.getConfiguration();
  // Mock an HConnection and a HRegionInterface implementation.  Have the
  // HConnection return the HRI.  Have the HRI return a few mocked up responses
  // to make our test work.
  this.connection =
    HConnectionTestingUtility.getMockedConnectionAndDecorate(this.c,
      Mockito.mock(HRegionInterface.class),
      new ServerName("example.org,12345,6789"),
      HRegionInfo.FIRST_META_REGIONINFO);
  // Set hbase.rootdir into test dir.
  FileSystem fs = FileSystem.get(this.c);
  Path rootdir = fs.makeQualified(new Path(this.c.get(HConstants.HBASE_DIR)));
  this.c.set(HConstants.HBASE_DIR, rootdir.toString());
  this.ct = Mockito.mock(CatalogTracker.class);
  HRegionInterface hri = Mockito.mock(HRegionInterface.class);
  Mockito.when(this.ct.getConnection()).thenReturn(this.connection);
  Mockito.when(ct.waitForMetaServerConnection(Mockito.anyLong())).thenReturn(hri);
}
项目:ditb    文件:ProcedureSyncWait.java   
protected static void waitMetaRegions(final MasterProcedureEnv env) throws IOException {
  int timeout = env.getMasterConfiguration().getInt("hbase.client.catalog.timeout", 10000);
  try {
    if (env.getMasterServices().getMetaTableLocator().waitMetaRegionLocation(
          env.getMasterServices().getZooKeeper(), timeout) == null) {
      throw new NotAllMetaRegionsOnlineException();
    }
  } catch (InterruptedException e) {
    throw (InterruptedIOException)new InterruptedIOException().initCause(e);
  }
}
项目:LCIndex-HBase-0.94.16    文件:MetaEditor.java   
public static void addDaughter(final CatalogTracker catalogTracker,
    final HRegionInfo regionInfo, final ServerName sn)
throws NotAllMetaRegionsOnlineException, IOException {
  Put put = new Put(regionInfo.getRegionName());
  addRegionInfo(put, regionInfo);
  if (sn != null) addLocation(put, sn);
  putToMetaTable(catalogTracker, put);
  LOG.info("Added daughter " + regionInfo.getRegionNameAsString() +
    (sn == null? ", serverName=null": ", serverName=" + sn.toString()));
}
项目:HIndex    文件:MetaEditor.java   
/**
 * Adds a daughter region entry to meta.
 * @param regionInfo the region to put
 * @param sn the location of the region
 * @param openSeqNum the latest sequence number obtained when the region was open
 */
public static void addDaughter(final CatalogTracker catalogTracker,
    final HRegionInfo regionInfo, final ServerName sn, final long openSeqNum)
throws NotAllMetaRegionsOnlineException, IOException {
  Put put = new Put(regionInfo.getRegionName());
  addRegionInfo(put, regionInfo);
  if (sn != null) {
    addLocation(put, sn, openSeqNum);
  }
  putToMetaTable(catalogTracker, put);
  LOG.info("Added daughter " + regionInfo.getEncodedName() +
    (sn == null? ", serverName=null": ", serverName=" + sn.toString()));
}