private static Long latestVersion(Hashtable<String, String> config, dbutil db_util) throws Exception { if (!config.get("timestamp_stop").equals(Integer.toString(Integer.MAX_VALUE))) { return new Long(config.get("timestamp_stop")); } String rowName = config.get("file_id") + config.get("run_id") + "_"; if (config.get("task_id") != "") { try { rowName = rowName + String.format("%04d", new Integer(config.get("task_id"))); } catch (NumberFormatException E) { rowName = rowName + config.get("task_id"); } } Get timestampGet = new Get(rowName.getBytes()); timestampGet.addColumn("d".getBytes(), "update".getBytes()); Result timestampResult = db_util.doGet(config.get("db_name_updates"), timestampGet); KeyValue tsKv = timestampResult.getColumnLatest("d".getBytes(), "update".getBytes()); if (tsKv == null) { rowName = config.get("file_id") + "_"; timestampGet = new Get(rowName.getBytes()); timestampGet.addColumn("d".getBytes(), "update".getBytes()); timestampResult = db_util.doGet(config.get("db_name_updates"), timestampGet); tsKv = timestampResult.getColumnLatest("d".getBytes(), "update".getBytes()); } if (tsKv == null) { return new Long(Integer.MAX_VALUE); } Long latestVersion = new Long(tsKv.getTimestamp()); return latestVersion; }
public Get get(Long userId, Long id) throws IOException { Get get = new Get(client); get.setUserId(userId); get.setId(id); client.initialize(get); return get; }
/** * Test concurrent reader and writer (GH-458). * * <p><b>Test case:</b> * * <ol> * <li/>start a long running reader; * <li/>try to start a writer: it should time out; * <li/>stop the reader; * <li/>start the writer again: it should succeed. * </ol> * * @throws Exception error during request execution */ @Test @Ignore("There is no way to stop a query on the server!") public void testReaderWriter() throws Exception { final String readerQuery = "?query=(1%20to%20100000000000000)%5b.=1%5d"; final String writerQuery = "/test.xml"; final byte[] content = Token.token("<a/>"); final Get readerAction = new Get(readerQuery); final Put writerAction = new Put(writerQuery, content); final ExecutorService exec = Executors.newFixedThreadPool(2); // start reader exec.submit(readerAction); Performance.sleep(TIMEOUT); // delay in order to be sure that the reader has started // start writer Future<HTTPResponse> writer = exec.submit(writerAction); try { final HTTPResponse result = writer.get(TIMEOUT, TimeUnit.MILLISECONDS); if (result.status.isSuccess()) fail("Database modified while a reader is running"); throw new Exception(result.toString()); } catch (final TimeoutException e) { // writer is blocked by the reader: stop it writerAction.stop = true; } // stop reader readerAction.stop = true; // start the writer again writer = exec.submit(writerAction); assertEquals(HTTPCode.CREATED, writer.get().status); }
public static void readTest(String tableStr, String row) { try { Configuration conf = HBaseConfiguration.create(); byte[] tableName = Bytes.toBytes(tableStr); HConnection hConnection = HConnectionManager.createConnection(conf); HTableInterface table = hConnection.getTable(tableName); byte[] rowkey = Bytes.toBytes(row); Get get = new Get(rowkey); get.addFamily(f0); Result result = table.get(get); NavigableMap<byte[], byte[]> m = result.getFamilyMap(f0); if (m == null || m.isEmpty()) { System.err.println("Empty." + m); return; } for (Map.Entry<byte[], byte[]> entry : m.entrySet()) { String qualifier = Bytes.toString(entry.getKey()); String value = Bytes.toString(entry.getValue()); System.out.println(qualifier + ":" + value); } table.close(); // very important } catch (IOException e) { e.printStackTrace(); } }
@Test(timeout = 30000) public void testCreateDeleteTable() throws IOException { // Create table then get the single region for our new table. HTableDescriptor hdt = HTU.createTableDescriptor("testCreateDeleteTable"); hdt.setRegionReplication(NB_SERVERS); hdt.addCoprocessor(SlowMeCopro.class.getName()); Table table = HTU.createTable(hdt, new byte[][] {f}, HTU.getConfiguration()); Put p = new Put(row); p.add(f, row, row); table.put(p); Get g = new Get(row); Result r = table.get(g); Assert.assertFalse(r.isStale()); try { // But if we ask for stale we will get it SlowMeCopro.cdl.set(new CountDownLatch(1)); g = new Get(row); g.setConsistency(Consistency.TIMELINE); r = table.get(g); Assert.assertTrue(r.isStale()); SlowMeCopro.cdl.get().countDown(); } finally { SlowMeCopro.cdl.get().countDown(); SlowMeCopro.sleepTime.set(0); } HTU.getHBaseAdmin().disableTable(hdt.getTableName()); HTU.deleteTable(hdt.getTableName()); }
@Test(timeout = 120000) public void testChangeTable() throws Exception { HTableDescriptor hdt = HTU.createTableDescriptor("testChangeTable"); hdt.setRegionReplication(NB_SERVERS); hdt.addCoprocessor(SlowMeCopro.class.getName()); Table table = HTU.createTable(hdt, new byte[][] {f}, HTU.getConfiguration()); // basic test: it should work. Put p = new Put(row); p.add(f, row, row); table.put(p); Get g = new Get(row); Result r = table.get(g); Assert.assertFalse(r.isStale()); // Add a CF, it should work. HTableDescriptor bHdt = HTU.getHBaseAdmin().getTableDescriptor(hdt.getTableName()); HColumnDescriptor hcd = new HColumnDescriptor(row); hdt.addFamily(hcd); HTU.getHBaseAdmin().disableTable(hdt.getTableName()); HTU.getHBaseAdmin().modifyTable(hdt.getTableName(), hdt); HTU.getHBaseAdmin().enableTable(hdt.getTableName()); HTableDescriptor nHdt = HTU.getHBaseAdmin().getTableDescriptor(hdt.getTableName()); Assert.assertEquals( "fams=" + Arrays.toString(nHdt.getColumnFamilies()), bHdt.getColumnFamilies().length + 1, nHdt.getColumnFamilies().length); p = new Put(row); p.add(row, row, row); table.put(p); g = new Get(row); r = table.get(g); Assert.assertFalse(r.isStale()); try { SlowMeCopro.cdl.set(new CountDownLatch(1)); g = new Get(row); g.setConsistency(Consistency.TIMELINE); r = table.get(g); Assert.assertTrue(r.isStale()); } finally { SlowMeCopro.cdl.get().countDown(); SlowMeCopro.sleepTime.set(0); } Admin admin = HTU.getHBaseAdmin(); nHdt = admin.getTableDescriptor(hdt.getTableName()); Assert.assertEquals( "fams=" + Arrays.toString(nHdt.getColumnFamilies()), bHdt.getColumnFamilies().length + 1, nHdt.getColumnFamilies().length); admin.disableTable(hdt.getTableName()); admin.deleteTable(hdt.getTableName()); admin.close(); }
/** * Algo: - we put the query into the execution pool. - after x ms, if we don't have a result, we * add the queries for the secondary replicas - we take the first answer - when done, we cancel * what's left. Cancelling means: - removing from the pool if the actual call was not started - * interrupting the call if it has started Client side, we need to take into account - a call is * not executed immediately after being put into the pool - a call is a thread. Let's not multiply * the number of thread by the number of replicas. Server side, if we can cancel when it's still * in the handler pool, it's much better, as a call can take some i/o. * * <p>Globally, the number of retries, timeout and so on still applies, but it's per replica, not * global. We continue until all retries are done, or all timeouts are exceeded. */ public synchronized Result call() throws DoNotRetryIOException, InterruptedIOException, RetriesExhaustedException { boolean isTargetReplicaSpecified = (get.getReplicaId() >= 0); RegionLocations rl = getRegionLocations( true, (isTargetReplicaSpecified ? get.getReplicaId() : RegionReplicaUtil.DEFAULT_REPLICA_ID), cConnection, tableName, get.getRow()); ResultBoundedCompletionService<Result> cs = new ResultBoundedCompletionService<Result>(this.rpcRetryingCallerFactory, pool, rl.size()); if (isTargetReplicaSpecified) { addCallsForReplica(cs, rl, get.getReplicaId(), get.getReplicaId()); } else { addCallsForReplica(cs, rl, 0, 0); try { // wait for the timeout to see whether the primary responds back Future<Result> f = cs.poll(timeBeforeReplicas, TimeUnit.MICROSECONDS); // Yes, microseconds if (f != null) { return f.get(); // great we got a response } } catch (ExecutionException e) { throwEnrichedException(e, retries); } catch (CancellationException e) { throw new InterruptedIOException(); } catch (InterruptedException e) { throw new InterruptedIOException(); } // submit call for the all of the secondaries at once addCallsForReplica(cs, rl, 1, rl.size() - 1); } try { try { Future<Result> f = cs.take(); return f.get(); } catch (ExecutionException e) { throwEnrichedException(e, retries); } } catch (CancellationException e) { throw new InterruptedIOException(); } catch (InterruptedException e) { throw new InterruptedIOException(); } finally { // We get there because we were interrupted or because one or more of the // calls succeeded or failed. In all case, we stop all our tasks. cs.cancelAll(); } return null; // unreachable }
private void appendOperations(SyncmlBody syncmlBody) throws WindowsOperationException { Get getElement = new Get(); List<Item> itemsGet = new ArrayList<Item>(); Exec execElement = new Exec(); List<Item> itemsExec = new ArrayList<Item>(); Atomic atomicElement = new Atomic(); List<Add> addsAtomic = new ArrayList<Add>(); if (operations != null) { for (int x = 0; x < operations.size(); x++) { Operation operation = operations.get(x); Operation.Type type = operation.getType(); switch (type) { case CONFIG: List<Add> addConfig = appendAddConfiguration(operation); for (Add addConfiguration : addConfig) { addsAtomic.add(addConfiguration); } break; case MESSAGE:; break; case INFO: Item itemGet = appendGetInfo(operation); itemsGet.add(itemGet); break; case COMMAND: Item itemExec = appendExecInfo(operation); itemsExec.add(itemExec); break; default: throw new WindowsOperationException("Operation with no type found"); } } } if (!itemsGet.isEmpty()) { getElement.setCommandId(75); getElement.setItems(itemsGet); } if (!itemsExec.isEmpty()) { execElement.setCommandId(5); execElement.setItems(itemsExec); } if (!addsAtomic.isEmpty()) { atomicElement.setCommandId(300); atomicElement.setAdds(addsAtomic); } syncmlBody.setGet(getElement); syncmlBody.setExec(execElement); }
@Test public void restMethodNameMultipleClientRequest() { Get get = new Get("twitter", "tweet", "1"); assertEquals("GET", get.getRestMethodName()); Delete del = new Delete("Silvester", "Stallone", "2"); assertEquals("DELETE", del.getRestMethodName()); assertEquals("GET", get.getRestMethodName()); Percolate percolate = new Percolate("Celtic", "Boston", "{\"Really good query\"}"); assertEquals("PUT", percolate.getRestMethodName()); assertEquals("GET", get.getRestMethodName()); }
@Test(timeout = 300000) public void testDisableAndEnableTables() throws IOException { final byte[] row = Bytes.toBytes("row"); final byte[] qualifier = Bytes.toBytes("qualifier"); final byte[] value = Bytes.toBytes("value"); final TableName table1 = TableName.valueOf("testDisableAndEnableTable1"); final TableName table2 = TableName.valueOf("testDisableAndEnableTable2"); Table ht1 = TEST_UTIL.createTable(table1, HConstants.CATALOG_FAMILY); Table ht2 = TEST_UTIL.createTable(table2, HConstants.CATALOG_FAMILY); Put put = new Put(row); put.add(HConstants.CATALOG_FAMILY, qualifier, value); ht1.put(put); ht2.put(put); Get get = new Get(row); get.addColumn(HConstants.CATALOG_FAMILY, qualifier); ht1.get(get); ht2.get(get); this.admin.disableTables("testDisableAndEnableTable.*"); // Test that tables are disabled get = new Get(row); get.addColumn(HConstants.CATALOG_FAMILY, qualifier); boolean ok = false; try { ht1.get(get); ht2.get(get); } catch (org.apache.hadoop.hbase.DoNotRetryIOException e) { ok = true; } assertTrue(ok); this.admin.enableTables("testDisableAndEnableTable.*"); // Test that tables are enabled try { ht1.get(get); } catch (IOException e) { ok = false; } try { ht2.get(get); } catch (IOException e) { ok = false; } assertTrue(ok); ht1.close(); ht2.close(); }
/** * Gets the parameters of the GetCapabilities capability answer. * * @return The operation type representing the GetCapabilities operation. */ private OperationType getCapOperation(WMSResponse wmsResponse) { OperationType opCap = new OperationType(); opCap.getFormat().add("text/xml"); Get getCap = new Get(); getCap.setOnlineResource( buildOnlineResource(wmsResponse, WMSProperties.CAP_GET, "GetCapabilities")); Post postCap = new Post(); postCap.setOnlineResource( buildOnlineResource(wmsResponse, WMSProperties.CAP_POST, "GetCapabilities")); HTTP httpCap = new HTTP(); httpCap.setGet(getCap); httpCap.setPost(postCap); DCPType dcpTypeCap = new DCPType(); dcpTypeCap.setHTTP(httpCap); opCap.getDCPType().add(dcpTypeCap); return opCap; }
@Override public GetResult get(Get get, Function<String, Searcher> searcherFactory) throws EngineException { try (ReleasableLock lock = readLock.acquire()) { ensureOpen(); if (get.realtime()) { VersionValue versionValue = versionMap.getUnderLock(get.uid().bytes()); if (versionValue != null) { if (versionValue.delete()) { return GetResult.NOT_EXISTS; } if (get.versionType().isVersionConflictForReads(versionValue.version(), get.version())) { Uid uid = Uid.createUid(get.uid().text()); throw new VersionConflictEngineException( shardId, uid.type(), uid.id(), get.versionType().explainConflictForReads(versionValue.version(), get.version())); } Translog.Operation op = translog.read(versionValue.translogLocation()); if (op != null) { return new GetResult(true, versionValue.version(), op.getSource()); } } } // no version, get the version from the index, we know that we refresh on flush return getFromSearcher(get, searcherFactory); } }
/** * Gets the parameters of the GetMap capability answer. * * @return The operation type representing the getMap operation. */ private OperationType getMapOperation(WMSResponse wmsResponse) { OperationType opMap = new OperationType(); for (ImageFormats im : ImageFormats.values()) { opMap.getFormat().add(im.toString()); } Get get = new Get(); get.setOnlineResource(buildOnlineResource(wmsResponse, WMSProperties.MAP_GET, "GetMap")); Post post = new Post(); post.setOnlineResource(buildOnlineResource(wmsResponse, WMSProperties.MAP_POST, "GetMap")); // We feed the http object HTTP http = new HTTP(); http.setGet(get); http.setPost(post); DCPType dcpType = new DCPType(); dcpType.setHTTP(http); opMap.getDCPType().add(dcpType); return opMap; }
private OperationType getFeatureOperation(WMSResponse wmsResponse) { OperationType opFeature = new OperationType(); opFeature.getFormat().add("text/xml"); // GET Get getFeature = new Get(); getFeature.setOnlineResource( buildOnlineResource(wmsResponse, WMSProperties.FEATURE_GET, "GetFeatureInfo")); // POST Post postFeature = new Post(); postFeature.setOnlineResource( buildOnlineResource(wmsResponse, WMSProperties.FEATURE_POST, "GetFeatureInfo")); // Both in HTTP HTTP httpFeature = new HTTP(); httpFeature.setGet(getFeature); httpFeature.setPost(postFeature); DCPType dcpTypeFeature = new DCPType(); dcpTypeFeature.setHTTP(httpFeature); opFeature.getDCPType().add(dcpTypeFeature); return opFeature; }
@Test public void testDisableAndEnableTable() throws IOException { final byte[] row = Bytes.toBytes("row"); final byte[] qualifier = Bytes.toBytes("qualifier"); final byte[] value = Bytes.toBytes("value"); final byte[] table = Bytes.toBytes("testDisableAndEnableTable"); HTable ht = TEST_UTIL.createTable(table, HConstants.CATALOG_FAMILY); Put put = new Put(row); put.add(HConstants.CATALOG_FAMILY, qualifier, value); ht.put(put); Get get = new Get(row); get.addColumn(HConstants.CATALOG_FAMILY, qualifier); ht.get(get); this.admin.disableTable(table); // Test that table is disabled get = new Get(row); get.addColumn(HConstants.CATALOG_FAMILY, qualifier); boolean ok = false; try { ht.get(get); } catch (NotServingRegionException e) { ok = true; } catch (RetriesExhaustedException e) { ok = true; } assertTrue(ok); this.admin.enableTable(table); // Test that table is enabled try { ht.get(get); } catch (RetriesExhaustedException e) { ok = false; } assertTrue(ok); }
/** * Test 2 concurrent readers (GH-458). * * <p><b>Test case:</b> * * <ol> * <li/>start a long running reader; * <li/>start a fast reader: it should succeed. * </ol> * * @throws Exception error during request execution */ @Test public void testMultipleReaders() throws Exception { final String number = "63177"; final String slowQuery = "?query=(1%20to%20100000000000000)%5b.=1%5d"; final String fastQuery = "?query=" + number; final Get slowAction = new Get(slowQuery); final Get fastAction = new Get(fastQuery); final ExecutorService exec = Executors.newFixedThreadPool(2); exec.submit(slowAction); Performance.sleep(TIMEOUT); // delay in order to be sure that the reader has started final Future<HTTPResponse> fast = exec.submit(fastAction); try { final HTTPResponse result = fast.get(TIMEOUT, TimeUnit.MILLISECONDS); assertEquals(HTTPCode.OK, result.status); assertEquals(number, result.data); } finally { slowAction.stop = true; } }
@Test(timeout = 30000) public void testBulkLoad() throws IOException { // Create table then get the single region for our new table. LOG.debug("Creating test table"); HTableDescriptor hdt = HTU.createTableDescriptor("testBulkLoad"); hdt.setRegionReplication(NB_SERVERS); hdt.addCoprocessor(SlowMeCopro.class.getName()); Table table = HTU.createTable(hdt, new byte[][] {f}, HTU.getConfiguration()); // create hfiles to load. LOG.debug("Creating test data"); Path dir = HTU.getDataTestDirOnTestFS("testBulkLoad"); final int numRows = 10; final byte[] qual = Bytes.toBytes("qual"); final byte[] val = Bytes.toBytes("val"); final List<Pair<byte[], String>> famPaths = new ArrayList<Pair<byte[], String>>(); for (HColumnDescriptor col : hdt.getColumnFamilies()) { Path hfile = new Path(dir, col.getNameAsString()); TestHRegionServerBulkLoad.createHFile( HTU.getTestFileSystem(), hfile, col.getName(), qual, val, numRows); famPaths.add(new Pair<byte[], String>(col.getName(), hfile.toString())); } // bulk load HFiles LOG.debug("Loading test data"); @SuppressWarnings("deprecation") final HConnection conn = HTU.getHBaseAdmin().getConnection(); RegionServerCallable<Void> callable = new RegionServerCallable<Void>( conn, hdt.getTableName(), TestHRegionServerBulkLoad.rowkey(0)) { @Override public Void call(int timeout) throws Exception { LOG.debug( "Going to connect to server " + getLocation() + " for row " + Bytes.toStringBinary(getRow())); byte[] regionName = getLocation().getRegionInfo().getRegionName(); BulkLoadHFileRequest request = RequestConverter.buildBulkLoadHFileRequest(famPaths, regionName, true); getStub().bulkLoadHFile(null, request); return null; } }; RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(HTU.getConfiguration()); RpcRetryingCaller<Void> caller = factory.<Void>newCaller(); caller.callWithRetries(callable, 10000); // verify we can read them from the primary LOG.debug("Verifying data load"); for (int i = 0; i < numRows; i++) { byte[] row = TestHRegionServerBulkLoad.rowkey(i); Get g = new Get(row); Result r = table.get(g); Assert.assertFalse(r.isStale()); } // verify we can read them from the replica LOG.debug("Verifying replica queries"); try { SlowMeCopro.cdl.set(new CountDownLatch(1)); for (int i = 0; i < numRows; i++) { byte[] row = TestHRegionServerBulkLoad.rowkey(i); Get g = new Get(row); g.setConsistency(Consistency.TIMELINE); Result r = table.get(g); Assert.assertTrue(r.isStale()); } SlowMeCopro.cdl.get().countDown(); } finally { SlowMeCopro.cdl.get().countDown(); SlowMeCopro.sleepTime.set(0); } HTU.getHBaseAdmin().disableTable(hdt.getTableName()); HTU.deleteTable(hdt.getTableName()); }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { String whatToDrop = null; Environmental target = mob; Vector V = new Vector(); if (commands.size() < 2) { mob.tell("Empty what where?"); return false; } commands.removeElementAt(0); if (commands.size() > 1) { String s = (String) commands.lastElement(); if (s.equalsIgnoreCase("here")) target = mob.location(); else if (s.equalsIgnoreCase("me")) target = mob; else if (s.equalsIgnoreCase("self")) target = mob; else if ("INVENTORY".startsWith(s.toUpperCase())) target = mob; else if (s.equalsIgnoreCase("floor")) target = mob.location(); else if (s.equalsIgnoreCase("ground")) target = mob.location(); else { target = CMLib.english().possibleContainer(mob, commands, false, Wearable.FILTER_UNWORNONLY); if (target == null) target = mob.location().fetchFromRoomFavorItems(null, s); else commands.addElement("delme"); } if (target != null) commands.removeElementAt(commands.size() - 1); } if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) { mob.tell("Empty it where?"); return false; } int maxToDrop = CMLib.english().calculateMaxToGive(mob, commands, true, mob, false); if (maxToDrop < 0) return false; whatToDrop = CMParms.combine(commands, 0); boolean allFlag = (commands.size() > 0) ? ((String) commands.elementAt(0)).equalsIgnoreCase("all") : false; if (whatToDrop.toUpperCase().startsWith("ALL.")) { allFlag = true; whatToDrop = "ALL " + whatToDrop.substring(4); } if (whatToDrop.toUpperCase().endsWith(".ALL")) { allFlag = true; whatToDrop = "ALL " + whatToDrop.substring(0, whatToDrop.length() - 4); } int addendum = 1; String addendumStr = ""; Drink drink = null; boolean doBugFix = true; while (doBugFix || ((allFlag) && (addendum <= maxToDrop))) { doBugFix = false; Item dropThis = mob.fetchCarried(null, whatToDrop + addendumStr); if ((dropThis == null) && (V.size() == 0) && (addendumStr.length() == 0) && (!allFlag)) { dropThis = mob.fetchWornItem(whatToDrop); if ((dropThis != null) && (dropThis instanceof Container)) { if ((!dropThis.amWearingAt(Wearable.WORN_HELD)) && (!dropThis.amWearingAt(Wearable.WORN_WIELD))) { mob.tell("You must remove that first."); return false; } CMMsg newMsg = CMClass.getMsg(mob, dropThis, null, CMMsg.MSG_REMOVE, null); if (mob.location().okMessage(mob, newMsg)) mob.location().send(mob, newMsg); else return false; } } if (dropThis == null) break; if (dropThis instanceof Drink) drink = (Drink) dropThis; if ((CMLib.flags().canBeSeenBy(dropThis, mob)) && (dropThis instanceof Container) && (!V.contains(dropThis))) V.addElement(dropThis); addendumStr = "." + (++addendum); } String str = "<S-NAME> empt(ys) <T-NAME>"; if (target instanceof Room) str += " here."; else if (target instanceof MOB) str += "."; else str += " into " + target.Name() + "."; if ((V.size() == 0) && (drink != null)) { mob.tell(drink.name() + " must be POURed out."); return false; } if (V.size() == 0) mob.tell("You don't seem to be carrying that."); else if ((V.size() == 1) && (V.firstElement() == target)) mob.tell("You can't empty something into itself!"); else if ((V.size() == 1) && (V.firstElement() instanceof Drink) && (!((Drink) V.firstElement()).containsDrink())) mob.tell(mob, (Drink) V.firstElement(), null, "<T-NAME> is already empty."); else for (int v = 0; v < V.size(); v++) { Container C = (Container) V.elementAt(v); if (C == target) continue; List<Item> V2 = C.getContents(); boolean skipMessage = false; if ((C instanceof Drink) && (((Drink) C).containsDrink())) { if (target instanceof Drink) { Command C2 = CMClass.getCommand("Pour"); C2.execute( mob, new XVector("POUR", "$" + C.Name() + "$", "$" + target.Name() + "$"), metaFlags); skipMessage = true; } else { ((Drink) C).setLiquidRemaining(0); if (((Drink) C).disappearsAfterDrinking()) C.destroy(); } } CMMsg msg = CMClass.getMsg(mob, C, CMMsg.MSG_QUIETMOVEMENT, str); Room R = mob.location(); if (skipMessage || (R.okMessage(mob, msg))) { if (!skipMessage) R.send(mob, msg); for (int v2 = 0; v2 < V2.size(); v2++) { Item I = (Item) V2.get(v2); if (I instanceof Coins) ((Coins) I).setContainer(null); if (((I.container() == null) || (Get.get(mob, C, I, true, null, true))) && (I.container() == null)) { if (target instanceof Room) drop(mob, I, true, true); else if (target instanceof Container) { CMMsg putMsg = CMClass.getMsg(mob, target, I, CMMsg.MASK_OPTIMIZE | CMMsg.MSG_PUT, null); if (R.okMessage(mob, putMsg)) R.send(mob, putMsg); } if (I instanceof Coins) ((Coins) I).putCoinsBack(); if (I instanceof RawMaterial) ((RawMaterial) I).rebundle(); } } } } mob.location().recoverRoomStats(); mob.location().recoverRoomStats(); return false; }
private static String sortedPrint(Iterable iter) { return As.list(Get.sorted(iter)).toString(); }
@Test(timeout = 300000) public void testDisableAndEnableTable() throws IOException { final byte[] row = Bytes.toBytes("row"); final byte[] qualifier = Bytes.toBytes("qualifier"); final byte[] value = Bytes.toBytes("value"); final TableName table = TableName.valueOf("testDisableAndEnableTable"); Table ht = TEST_UTIL.createTable(table, HConstants.CATALOG_FAMILY); Put put = new Put(row); put.add(HConstants.CATALOG_FAMILY, qualifier, value); ht.put(put); Get get = new Get(row); get.addColumn(HConstants.CATALOG_FAMILY, qualifier); ht.get(get); this.admin.disableTable(ht.getName()); assertTrue( "Table must be disabled.", TEST_UTIL .getHBaseCluster() .getMaster() .getAssignmentManager() .getTableStateManager() .isTableState(ht.getName(), ZooKeeperProtos.Table.State.DISABLED)); // Test that table is disabled get = new Get(row); get.addColumn(HConstants.CATALOG_FAMILY, qualifier); boolean ok = false; try { ht.get(get); } catch (TableNotEnabledException e) { ok = true; } ok = false; // verify that scan encounters correct exception Scan scan = new Scan(); try { ResultScanner scanner = ht.getScanner(scan); Result res = null; do { res = scanner.next(); } while (res != null); } catch (TableNotEnabledException e) { ok = true; } assertTrue(ok); this.admin.enableTable(table); assertTrue( "Table must be enabled.", TEST_UTIL .getHBaseCluster() .getMaster() .getAssignmentManager() .getTableStateManager() .isTableState(ht.getName(), ZooKeeperProtos.Table.State.ENABLED)); // Test that table is enabled try { ht.get(get); } catch (RetriesExhaustedException e) { ok = false; } assertTrue(ok); ht.close(); }