@Test public void setsCombinerOnMetadataCorrectly() throws Exception { AccumuloClient client = createMock(AccumuloClient.class); TableOperations tops = createMock(TableOperations.class); String myMetadataTable = "mymetadata"; Map<String,EnumSet<IteratorScope>> iterators = new HashMap<>(); iterators.put("vers", EnumSet.of(IteratorScope.majc, IteratorScope.minc, IteratorScope.scan)); IteratorSetting combiner = new IteratorSetting(9, "replcombiner", StatusCombiner.class); Combiner.setColumns(combiner, Collections.singletonList(new Column(ReplicationSection.COLF))); expect(client.tableOperations()).andReturn(tops); expect(tops.listIterators(myMetadataTable)).andReturn(iterators); tops.attachIterator(myMetadataTable, combiner); expectLastCall().once(); expect(tops.getProperties(myMetadataTable)).andReturn(Collections.emptyList()); tops.setProperty(myMetadataTable, Property.TABLE_FORMATTER_CLASS.getKey(), ReplicationTableUtil.STATUS_FORMATTER_CLASS_NAME); expectLastCall().once(); replay(client, tops); ReplicationTableUtil.configureMetadataTable(client, myMetadataTable); verify(client, tops); }
public synchronized static void configureMetadataTable(AccumuloClient client, String tableName) { TableOperations tops = client.tableOperations(); Map<String,EnumSet<IteratorScope>> iterators = null; try { iterators = tops.listIterators(tableName); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } if (!iterators.containsKey(COMBINER_NAME)) { IteratorSetting setting = new IteratorSetting(9, COMBINER_NAME, StatusCombiner.class); Combiner.setColumns(setting, Collections.singletonList(new Column(ReplicationSection.COLF))); try { tops.attachIterator(tableName, setting); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } } Iterable<Entry<String,String>> properties; try { properties = tops.getProperties(tableName); } catch (AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } for (Entry<String,String> property : properties) { if (Property.TABLE_FORMATTER_CLASS.getKey().equals(property.getKey())) { if (!STATUS_FORMATTER_CLASS_NAME.equals(property.getValue())) { log.info("Setting formatter for {} from {} to {}", tableName, property.getValue(), STATUS_FORMATTER_CLASS_NAME); try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } } return; } } try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } }
ReplicationTableUtil { public synchronized static void configureMetadataTable(AccumuloClient client, String tableName) { TableOperations tops = client.tableOperations(); Map<String,EnumSet<IteratorScope>> iterators = null; try { iterators = tops.listIterators(tableName); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } if (!iterators.containsKey(COMBINER_NAME)) { IteratorSetting setting = new IteratorSetting(9, COMBINER_NAME, StatusCombiner.class); Combiner.setColumns(setting, Collections.singletonList(new Column(ReplicationSection.COLF))); try { tops.attachIterator(tableName, setting); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } } Iterable<Entry<String,String>> properties; try { properties = tops.getProperties(tableName); } catch (AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } for (Entry<String,String> property : properties) { if (Property.TABLE_FORMATTER_CLASS.getKey().equals(property.getKey())) { if (!STATUS_FORMATTER_CLASS_NAME.equals(property.getValue())) { log.info("Setting formatter for {} from {} to {}", tableName, property.getValue(), STATUS_FORMATTER_CLASS_NAME); try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } } return; } } try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } } }
ReplicationTableUtil { public synchronized static void configureMetadataTable(AccumuloClient client, String tableName) { TableOperations tops = client.tableOperations(); Map<String,EnumSet<IteratorScope>> iterators = null; try { iterators = tops.listIterators(tableName); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } if (!iterators.containsKey(COMBINER_NAME)) { IteratorSetting setting = new IteratorSetting(9, COMBINER_NAME, StatusCombiner.class); Combiner.setColumns(setting, Collections.singletonList(new Column(ReplicationSection.COLF))); try { tops.attachIterator(tableName, setting); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } } Iterable<Entry<String,String>> properties; try { properties = tops.getProperties(tableName); } catch (AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } for (Entry<String,String> property : properties) { if (Property.TABLE_FORMATTER_CLASS.getKey().equals(property.getKey())) { if (!STATUS_FORMATTER_CLASS_NAME.equals(property.getValue())) { log.info("Setting formatter for {} from {} to {}", tableName, property.getValue(), STATUS_FORMATTER_CLASS_NAME); try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } } return; } } try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } } private  ReplicationTableUtil(); }
ReplicationTableUtil { public synchronized static void configureMetadataTable(AccumuloClient client, String tableName) { TableOperations tops = client.tableOperations(); Map<String,EnumSet<IteratorScope>> iterators = null; try { iterators = tops.listIterators(tableName); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } if (!iterators.containsKey(COMBINER_NAME)) { IteratorSetting setting = new IteratorSetting(9, COMBINER_NAME, StatusCombiner.class); Combiner.setColumns(setting, Collections.singletonList(new Column(ReplicationSection.COLF))); try { tops.attachIterator(tableName, setting); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } } Iterable<Entry<String,String>> properties; try { properties = tops.getProperties(tableName); } catch (AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } for (Entry<String,String> property : properties) { if (Property.TABLE_FORMATTER_CLASS.getKey().equals(property.getKey())) { if (!STATUS_FORMATTER_CLASS_NAME.equals(property.getValue())) { log.info("Setting formatter for {} from {} to {}", tableName, property.getValue(), STATUS_FORMATTER_CLASS_NAME); try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } } return; } } try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } } private  ReplicationTableUtil(); synchronized static void configureMetadataTable(AccumuloClient client, String tableName); static void updateFiles(ClientContext context, KeyExtent extent, String file,
      Status stat); }
ReplicationTableUtil { public synchronized static void configureMetadataTable(AccumuloClient client, String tableName) { TableOperations tops = client.tableOperations(); Map<String,EnumSet<IteratorScope>> iterators = null; try { iterators = tops.listIterators(tableName); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } if (!iterators.containsKey(COMBINER_NAME)) { IteratorSetting setting = new IteratorSetting(9, COMBINER_NAME, StatusCombiner.class); Combiner.setColumns(setting, Collections.singletonList(new Column(ReplicationSection.COLF))); try { tops.attachIterator(tableName, setting); } catch (AccumuloSecurityException | AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } } Iterable<Entry<String,String>> properties; try { properties = tops.getProperties(tableName); } catch (AccumuloException | TableNotFoundException e) { throw new RuntimeException(e); } for (Entry<String,String> property : properties) { if (Property.TABLE_FORMATTER_CLASS.getKey().equals(property.getKey())) { if (!STATUS_FORMATTER_CLASS_NAME.equals(property.getValue())) { log.info("Setting formatter for {} from {} to {}", tableName, property.getValue(), STATUS_FORMATTER_CLASS_NAME); try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } } return; } } try { tops.setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), STATUS_FORMATTER_CLASS_NAME); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException(e); } } private  ReplicationTableUtil(); synchronized static void configureMetadataTable(AccumuloClient client, String tableName); static void updateFiles(ClientContext context, KeyExtent extent, String file,
      Status stat); static final String COMBINER_NAME; static final String STATUS_FORMATTER_CLASS_NAME; }