AccumuloKeyRangePartitioner extends Partitioner { public static synchronized String[] getSplits(final AccumuloStore store) throws OperationException { final Connector connector; try { connector = store.getConnection(); } catch (final StoreException e) { throw new OperationException("Failed to create accumulo connection", e); } final String table = store.getTableName(); try { return connector.tableOperations() .listSplits(table) .stream() .sorted() .map(Text::toString) .toArray(String[]::new); } catch (final TableNotFoundException | AccumuloSecurityException | AccumuloException e) { throw new OperationException("Failed to get accumulo split points from table " + table, e); } } AccumuloKeyRangePartitioner(final AccumuloStore store); synchronized void setNumSubBins(final int numSubBins); @Override int numPartitions(); @Override int getPartition(final Object obj); static synchronized String[] getSplits(final AccumuloStore store);  }
@Test public void shouldGetSplitsInOrder() throws Exception { final AccumuloStore store = mock(AccumuloStore.class); final Connector connector = mock(ConnectorImpl.class); final TableOperations tableOperations = mock(TableOperations.class); final String testTableName = "tableName"; final List<Text> unsortedTextCollection = Arrays.asList(new Text("z"), new Text("f"), new Text("g"), new Text("a")); final List<String> sortedStringCollection = Arrays.asList("a", "f", "g", "z"); given(store.getConnection()).willReturn(connector); given(store.getTableName()).willReturn(testTableName); given(connector.tableOperations()).willReturn(tableOperations); given(connector.tableOperations().listSplits(testTableName)).willReturn(unsortedTextCollection); final List<String> splits = Arrays.asList(AccumuloKeyRangePartitioner.getSplits(store)); assertEquals(sortedStringCollection, splits); }