if (oldCommit != null) { commitHydrants.putAll(oldCommit.getHydrants()); writeCommit(new Committed(commitHydrants, commitMetadata));
@Test public void testWithout() { Assert.assertEquals(0, fixedInstance().without(IDENTIFIER1).getCommittedHydrants(IDENTIFIER1)); Assert.assertEquals(2, fixedInstance().without(IDENTIFIER1).getCommittedHydrants(IDENTIFIER2)); } }
@Test public void testSerde() throws Exception { final Committed committed = fixedInstance(); final byte[] bytes = objectMapper.writeValueAsBytes(committed); final Committed committed2 = objectMapper.readValue(bytes, Committed.class); Assert.assertEquals("Round trip: overall", committed, committed2); Assert.assertEquals("Round trip: metadata", committed.getMetadata(), committed2.getMetadata()); Assert.assertEquals("Round trip: identifiers", committed.getHydrants().keySet(), committed2.getHydrants().keySet()); }
committed = objectMapper.readValue(commitFile, Committed.class); } else { committed = Committed.nil(); log.info("Loading sinks from[%s]: %s", baseDir, committed.getHydrants().keySet()); ); final int committedHydrants = committed.getCommittedHydrants(identifier.toString()); Iterables.transform(sinks.keySet(), SegmentIdWithShardSpec::toString) ); final Set<String> missingSinks = Sets.difference(committed.getHydrants().keySet(), loadedSinks); if (!missingSinks.isEmpty()) { throw new ISE("Missing committed sinks [%s]", Joiner.on(", ").join(missingSinks)); return committed.getMetadata();
public Committed without(final String identifierAsString) { final Map<String, Integer> newHydrants = new HashMap<>(); newHydrants.putAll(hydrants); newHydrants.remove(identifierAsString); return new Committed(newHydrants, metadata); }
final Committed oldCommit = readCommit(); if (oldCommit != null) { writeCommit(oldCommit.without(identifier.toString()));
@Test public void testGetCommittedHydrant() { Assert.assertEquals(3, fixedInstance().getCommittedHydrants(IDENTIFIER1)); Assert.assertEquals(2, fixedInstance().getCommittedHydrants(IDENTIFIER2)); Assert.assertEquals(0, fixedInstance().getCommittedHydrants(IDENTIFIER3)); }
try { commitLock.lock(); objectMapper.writeValue(computeCommitFile(), Committed.nil());
@Test public void testFactoryMethod() { final Committed committed = fixedInstance(); final Committed committed2 = Committed.create( ImmutableMap.of( IDENTIFIER_OBJECT1, 3, IDENTIFIER_OBJECT2, 2 ), ImmutableMap.of("metadata", "foo") ); Assert.assertEquals(committed, committed2); }
committed = objectMapper.readValue(commitFile, Committed.class); } else { committed = Committed.nil(); log.info("Loading sinks from[%s]: %s", baseDir, committed.getHydrants().keySet()); ); final int committedHydrants = committed.getCommittedHydrants(identifier.getIdentifierAsString()); final Set<String> missingSinks = Sets.difference(committed.getHydrants().keySet(), loadedSinks); if (!missingSinks.isEmpty()) { throw new ISE("Missing committed sinks [%s]", Joiner.on(", ").join(missingSinks)); return committed.getMetadata();
public Committed with(final Map<String, Integer> hydrantsToAdd) { final Map<String, Integer> newHydrants = new HashMap<>(); newHydrants.putAll(hydrants); newHydrants.putAll(hydrantsToAdd); return new Committed(newHydrants, metadata); }
final Committed oldCommit = readCommit(); if (oldCommit != null) { writeCommit(oldCommit.without(identifier.getIdentifierAsString()));
try { commitLock.lock(); objectMapper.writeValue(computeCommitFile(), Committed.nil());
if (oldCommit != null) { commitHydrants.putAll(oldCommit.getHydrants()); writeCommit(new Committed(commitHydrants, commitMetadata));
public static Committed create( Map<SegmentIdWithShardSpec, Integer> hydrants0, Object metadata ) { final ImmutableMap.Builder<String, Integer> hydrants = ImmutableMap.builder(); for (Map.Entry<SegmentIdWithShardSpec, Integer> entry : hydrants0.entrySet()) { hydrants.put(entry.getKey().toString(), entry.getValue()); } return new Committed(hydrants.build(), metadata); }
private static Committed fixedInstance() { final Map<String, Integer> hydrants = new HashMap<>(); hydrants.put(IDENTIFIER1, 3); hydrants.put(IDENTIFIER2, 2); return new Committed(hydrants, ImmutableMap.of("metadata", "foo")); }
public Committed without(final String identifierAsString) { final Map<String, Integer> newHydrants = Maps.newHashMap(); newHydrants.putAll(hydrants); newHydrants.remove(identifierAsString); return new Committed(newHydrants, metadata); }
public Committed with(final Map<String, Integer> hydrantsToAdd) { final Map<String, Integer> newHydrants = Maps.newHashMap(); newHydrants.putAll(hydrants); newHydrants.putAll(hydrantsToAdd); return new Committed(newHydrants, metadata); }
public static Committed create( Map<SegmentIdentifier, Integer> hydrants0, Object metadata ) { final ImmutableMap.Builder<String, Integer> hydrants = ImmutableMap.builder(); for (Map.Entry<SegmentIdentifier, Integer> entry : hydrants0.entrySet()) { hydrants.put(entry.getKey().getIdentifierAsString(), entry.getValue()); } return new Committed(hydrants.build(), metadata); }