protected void merge(AccumuloClient client, String table, List<Size> sizes, int numToMerge) throws MergeException { try { Text start = sizes.get(0).extent.getPrevEndRow(); Text end = sizes.get(numToMerge - 1).extent.getEndRow(); message("Merging %d tablets from (%s to %s]", numToMerge, start == null ? "-inf" : start, end == null ? "+inf" : end); client.tableOperations().merge(table, start, end); } catch (Exception ex) { throw new MergeException(ex); } }
shellState.getAccumuloClient().tableOperations().merge(tableName, startRow, endRow); } else { final boolean finalVerbose = verbose;
@Override protected void doTableOp() throws Exception { c.tableOperations().merge(table, null, null); } }));
public void merge(String tableName, String startRow, String endRow) throws D4mException { TableOperations tops = this.connector.tableOperations(); try { tops.merge(tableName, startRow == null ? null : new Text(startRow), endRow == null ? null : new Text(endRow)); } catch (AccumuloException | TableNotFoundException | AccumuloSecurityException e) { log.warn("",e); throw new D4mException(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"); tableNames = new ArrayList<>(tableNames); tableNames.add(MetadataTable.NAME); String tableName = tableNames.get(rand.nextInt(tableNames.size())); List<Text> range = ConcurrentFixture.generateRange(rand); try { conn.tableOperations().merge(tableName, range.get(0), range.get(1)); log.debug("merged " + tableName + " from " + range.get(0) + " to " + range.get(1)); } catch (TableOfflineException toe) { log.debug("merge " + tableName + " from " + range.get(0) + " to " + range.get(1) + " failed, table is not online"); } catch (TableNotFoundException tne) { log.debug("merge " + tableName + " from " + range.get(0) + " to " + range.get(1) + " failed, doesnt exist"); } } }
@Before public void saveMetadataSplits() throws Exception { if (ClusterType.STANDALONE == getClusterType()) { Connector conn = getConnector(); Collection<Text> splits = conn.tableOperations().listSplits(MetadataTable.NAME); // We expect a single split if (!splits.equals(Arrays.asList(new Text("~")))) { log.info("Existing splits on metadata table. Saving them, and applying" + " single original split of '~'"); metadataSplits = splits; conn.tableOperations().merge(MetadataTable.NAME, null, null); conn.tableOperations().addSplits(MetadataTable.NAME, new TreeSet<>(Collections.singleton(new Text("~")))); } } }
protected void merge(Connector conn, String table, List<Size> sizes, int numToMerge) throws MergeException { try { Text start = sizes.get(0).extent.getPrevEndRow(); Text end = sizes.get(numToMerge - 1).extent.getEndRow(); message("Merging %d tablets from (%s to %s]", numToMerge, start == null ? "-inf" : start, end == null ? "+inf" : end); conn.tableOperations().merge(table, start, end); } catch (Exception ex) { throw new MergeException(ex); } }
@Test public void testRootTableMerge() throws Exception { TableOperations opts = getConnector().tableOperations(); opts.merge(RootTable.NAME, null, null); }
@Test public void testMetadataTableSplit() throws Exception { TableOperations opts = getConnector().tableOperations(); for (int i = 1; i <= 10; i++) { opts.create(Integer.toString(i)); } try { opts.merge(MetadataTable.NAME, new Text("01"), new Text("02")); checkMetadataSplits(1, opts); addSplits(opts, "4 5 6 7 8".split(" ")); checkMetadataSplits(6, opts); opts.merge(MetadataTable.NAME, new Text("6"), new Text("9")); checkMetadataSplits(4, opts); addSplits(opts, "44 55 66 77 88".split(" ")); checkMetadataSplits(9, opts); opts.merge(MetadataTable.NAME, new Text("5"), new Text("7")); checkMetadataSplits(6, opts); opts.merge(MetadataTable.NAME, null, null); checkMetadataSplits(0, opts); } finally { for (int i = 1; i <= 10; i++) { opts.delete(Integer.toString(i)); } } }
@After public void restoreMetadataSplits() throws Exception { if (null != metadataSplits) { log.info("Restoring split on metadata table"); Connector conn = getConnector(); conn.tableOperations().merge(MetadataTable.NAME, null, null); conn.tableOperations().addSplits(MetadataTable.NAME, new TreeSet<>(metadataSplits)); } }
@Override protected void runLater(State state, Environment env) throws Exception { Text[] points = getRandomTabletRange(state); log.info("merging " + rangeToString(points)); env.getConnector().tableOperations().merge(Setup.getTableName(), points[0], points[1]); log.info("merging " + rangeToString(points) + " complete"); }
@Override public void visit(State state, Environment env, Properties props) throws Exception { String table = state.getString("tableName"); Random rand = (Random) state.get("rand"); Connector conn = env.getConnector(); Text row1 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks")))); Text row2 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks")))); if (row1.compareTo(row2) >= 0) { row1 = null; row2 = null; } log.debug("merging " + row1 + " " + row2); conn.tableOperations().merge(table, row1, row2); }
@Override public void visit(State state, Environment env, Properties props) throws Exception { String indexTableName = (String) state.get("indexTableName"); Collection<Text> splits = env.getConnector().tableOperations().listSplits(indexTableName); SortedSet<Text> splitSet = new TreeSet<>(splits); log.debug("merging " + indexTableName); env.getConnector().tableOperations().merge(indexTableName, null, null); org.apache.accumulo.core.util.Merge merge = new org.apache.accumulo.core.util.Merge(); merge.mergomatic(env.getConnector(), indexTableName, null, null, 256 * 1024 * 1024, true); splits = env.getConnector().tableOperations().listSplits(indexTableName); if (splits.size() > splitSet.size()) { // throw an excpetion so that test will die an no further changes to table will occur... // this way table is left as is for debugging. throw new Exception( "There are more tablets after a merge: " + splits.size() + " was " + splitSet.size()); } }
conn.tableOperations().merge(table, start == null ? null : new Text(start), end == null ? null : new Text(end));
tops.merge(clonedTable, null, new Text("b"));
@Override public void mergeTablets(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { getConnector(login).tableOperations().merge(tableName, ByteBufferUtil.toText(startRow), ByteBufferUtil.toText(endRow)); } catch (Exception e) { handleExceptionTNF(e); } }
shellState.getConnector().tableOperations().merge(tableName, startRow, endRow); } else { final boolean finalVerbose = verbose;
@Test public void mergeMeta() throws Exception { Connector c = getConnector(); String[] names = getUniqueNames(5); SortedSet<Text> splits = new TreeSet<>(); for (String id : "1 2 3 4 5".split(" ")) { splits.add(new Text(id)); } c.tableOperations().addSplits(MetadataTable.NAME, splits); for (String tableName : names) { c.tableOperations().create(tableName); } c.tableOperations().merge(MetadataTable.NAME, null, null); Scanner s = c.createScanner(RootTable.NAME, Authorizations.EMPTY); s.setRange(MetadataSchema.DeletesSection.getRange()); while (Iterators.size(s.iterator()) == 0) { sleepUninterruptibly(100, TimeUnit.MILLISECONDS); } assertEquals(0, c.tableOperations().listSplits(MetadataTable.NAME).size()); }
private void runMergeTest(Connector conn, String table, String[] splits, String[] inserts, String start, String end, String last, long expected) throws Exception { log.info("table " + table); conn.tableOperations().create(table, new NewTableConfiguration().setTimeType(TimeType.LOGICAL)); TreeSet<Text> splitSet = new TreeSet<>(); for (String split : splits) { splitSet.add(new Text(split)); } conn.tableOperations().addSplits(table, splitSet); BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig()); for (String row : inserts) { Mutation m = new Mutation(row); m.put("cf", "cq", "v"); bw.addMutation(m); } bw.flush(); conn.tableOperations().merge(table, start == null ? null : new Text(start), end == null ? null : new Text(end)); Mutation m = new Mutation(last); m.put("cf", "cq", "v"); bw.addMutation(m); bw.flush(); Scanner scanner = conn.createScanner(table, Authorizations.EMPTY); scanner.setRange(new Range(last)); bw.close(); long time = scanner.iterator().next().getKey().getTimestamp(); if (time != expected) throw new RuntimeException("unexpected time " + time + " " + expected); }
@Test public void merge() throws Exception { Connector c = getConnector(); String tableName = getUniqueNames(1)[0]; c.tableOperations().create(tableName); c.tableOperations().addSplits(tableName, splits("a b c d e f g h i j k".split(" "))); BatchWriter bw = c.createBatchWriter(tableName, null); for (String row : "a b c d e f g h i j k".split(" ")) { Mutation m = new Mutation(row); m.put("cf", "cq", "value"); bw.addMutation(m); } bw.close(); c.tableOperations().flush(tableName, null, null, true); c.tableOperations().merge(tableName, new Text("c1"), new Text("f1")); assertEquals(8, c.tableOperations().listSplits(tableName).size()); }