@Override protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (tableName.equals(MetadataTable.NAME)) { Shell.log.info(" You cannot take the " + MetadataTable.NAME + " offline."); } else { shellState.getAccumuloClient().tableOperations().offline(tableName, wait); Shell.log.info("Offline of table " + tableName + (wait ? " completed." : " initiated...")); } }
if (tableState != TableState.OFFLINE) { log.info("Taking {} offline", tableName); context.tableOperations().offline(tableName, true); log.info("{} offline", tableName);
protected void takeTablesOffline(Connector conn, List<String> tableNames) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { for (String tableName : tableNames) { LOGGER.debug("taking table " + tableName + " offline"); conn.tableOperations().offline(tableName); } }
@Override protected void doTableOp() throws Exception { c.tableOperations().offline(table); } }));
@Override protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (tableName.equals(MetadataTable.NAME)) { Shell.log.info(" You cannot take the " + MetadataTable.NAME + " offline."); } else { shellState.getConnector().tableOperations().offline(tableName, wait); Shell.log.info("Offline of table " + tableName + (wait ? " completed." : " initiated...")); } }
@Override public void visit(State state, Environment env, Properties props) throws Exception { @SuppressWarnings("unchecked") List<String> tables = (List<String>) state.get("tableList"); if (tables.size() <= 0) { return; } Random rand = new Random(); String tableName = tables.get(rand.nextInt(tables.size())); env.getConnector().tableOperations().offline(tableName, rand.nextBoolean()); log.debug("Table " + tableName + " offline "); env.getConnector().tableOperations().online(tableName, rand.nextBoolean()); log.debug("Table " + tableName + " online "); } }
private static void setupLocalityGroups(Connector conn, int numlg, ArrayList<byte[]> cfset, String table) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { if (numlg > 1) { int numCF = cfset.size() / numlg; int gNum = 0; Iterator<byte[]> cfiter = cfset.iterator(); Map<String,Set<Text>> groups = new HashMap<>(); while (cfiter.hasNext()) { HashSet<Text> groupCols = new HashSet<>(); for (int i = 0; i < numCF && cfiter.hasNext(); i++) { groupCols.add(new Text(cfiter.next())); } groups.put("lg" + (gNum++), groupCols); } conn.tableOperations().setLocalityGroups(table, groups); conn.tableOperations().offline(table); sleepUninterruptibly(1, TimeUnit.SECONDS); conn.tableOperations().online(table); } }
@Override public void offlineTable(ByteBuffer login, String tableName, boolean wait) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { getConnector(login).tableOperations().offline(tableName, wait); } catch (Exception e) { handleExceptionTNF(e); } }
@Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); try { conn.tableOperations().offline(tableName, rand.nextBoolean()); log.debug("Offlined " + tableName); sleepUninterruptibly(rand.nextInt(200), TimeUnit.MILLISECONDS); conn.tableOperations().online(tableName, rand.nextBoolean()); log.debug("Onlined " + tableName); } catch (TableNotFoundException tne) { log.debug("offline or online failed " + tableName + ", doesnt exist"); } catch (AccumuloException ae) { if (ae.getMessage().startsWith("Unexpected table state")) { log.debug("offline or online failed " + tableName + ", unexpected table state"); } else { throw ae; } } } }
private void createTable(String t, boolean online) throws AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException { Connector conn = getConnector(); conn.tableOperations().create(t); conn.tableOperations().online(t, true); SortedSet<Text> partitionKeys = new TreeSet<>(); partitionKeys.add(new Text("some split")); conn.tableOperations().addSplits(t, partitionKeys); if (!online) { conn.tableOperations().offline(t, true); } }
c.tableOperations().offline(table2, true); log.info("Offlined " + table2);
private void updateSamplingConfig(Connector conn, String tableName, SamplerConfiguration sc) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { conn.tableOperations().setSamplerConfiguration(tableName, sc); // wait for for config change conn.tableOperations().offline(tableName, true); conn.tableOperations().online(tableName, true); }
/** * Create splits on table and force migration by taking table offline and then bring back online * for test. * * @param conn * Accumulo connector Accumulo connector to test cluster or MAC instance. */ private void addSplits(final Connector conn, final String tableName) { SortedSet<Text> splits = createSplits(); try { conn.tableOperations().addSplits(tableName, splits); conn.tableOperations().offline(tableName, true); sleepUninterruptibly(2, TimeUnit.SECONDS); conn.tableOperations().online(tableName, true); for (Text split : conn.tableOperations().listSplits(tableName)) { log.trace("Split {}", split); } } catch (AccumuloSecurityException e) { throw new IllegalStateException("Initialization failed. Could not add splits to " + tableName, e); } catch (TableNotFoundException e) { throw new IllegalStateException("Initialization failed. Could not add splits to " + tableName, e); } catch (AccumuloException e) { throw new IllegalStateException("Initialization failed. Could not add splits to " + tableName, e); } }
@Before public void offlineTraceTable() throws Exception { Connector conn = getConnector(); String traceTable = conn.instanceOperations().getSystemConfiguration() .get(Property.TRACE_TABLE.getKey()); if (conn.tableOperations().exists(traceTable)) { conn.tableOperations().offline(traceTable, true); } }
conn.tableOperations().offline(tableName, true);
@Before public void setupTables() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException { Connector conn = getConnector(); // Need at least two tservers Assume.assumeTrue("Not enough tservers to run test", conn.instanceOperations().getTabletServers().size() >= 2); // set up splits final SortedSet<Text> splits = new TreeSet<>(); for (int i = 0; i < NUM_SPLITS; i++) { splits.add(new Text(String.format("%08x", i * 1000))); } String[] names = getUniqueNames(2); UNUSED_TABLE = names[0]; TEST_TABLE = names[1]; // load into a table we won't use connector = getConnector(); connector.tableOperations().create(UNUSED_TABLE); connector.tableOperations().addSplits(UNUSED_TABLE, splits); // mark the table offline before it can rebalance. connector.tableOperations().offline(UNUSED_TABLE); // actual test table connector.tableOperations().create(TEST_TABLE); connector.tableOperations().setProperty(TEST_TABLE, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K"); }
private Scanner newOfflineScanner(Connector conn, String tableName, String clone, SamplerConfiguration sc) throws Exception { if (conn.tableOperations().exists(clone)) { conn.tableOperations().delete(clone); } Map<String,String> em = Collections.emptyMap(); Set<String> es = Collections.emptySet(); conn.tableOperations().clone(tableName, clone, false, em, es); conn.tableOperations().offline(clone, true); String cloneID = conn.tableOperations().tableIdMap().get(clone); OfflineScanner oScanner = new OfflineScanner(conn.getInstance(), new Credentials(getAdminPrincipal(), getAdminToken()), cloneID, Authorizations.EMPTY); if (sc != null) { oScanner.setSamplerConfiguration(sc); } return oScanner; }
c.tableOperations().offline(tableName);
@Test public void testOffline() throws Exception { String table = getUniqueNames(1)[0]; Connector conn = getConnector(); conn.tableOperations().create(table); try ( ConditionalWriter cw = conn.createConditionalWriter(table, new ConditionalWriterConfig())) { conn.tableOperations().offline(table, true); ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq")); cm1.put("tx", "seq", "1"); cm1.put("data", "x", "a"); Result result = cw.write(cm1); try { Status status = result.getStatus(); Assert.fail("Expected exception writing conditional mutation to offline table. Got status: " + status); } catch (AccumuloException ae) { Assert.assertEquals(TableOfflineException.class, ae.getCause().getClass()); } try { conn.createConditionalWriter(table, new ConditionalWriterConfig()); Assert.fail("Expected exception creating conditional writer to offline table"); } catch (TableOfflineException e) {} } }
c.tableOperations().offline(tableName, true); TabletLocationState offline = getTabletLocationState(c, tableId); assertNull(offline.future);