use of org.skife.jdbi.v2.Update in project druid by druid-io.
the class IndexerSQLMetadataStorageCoordinatorTest method testAnnounceHistoricalSegments.
@Test
public void testAnnounceHistoricalSegments() throws IOException {
Set<DataSegment> segments = new HashSet<>();
for (int i = 0; i < 105; i++) {
segments.add(new DataSegment("fooDataSource", Intervals.of("2015-01-01T00Z/2015-01-02T00Z"), "version", ImmutableMap.of(), ImmutableList.of("dim1"), ImmutableList.of("m1"), new LinearShardSpec(i), 9, 100));
}
coordinator.announceHistoricalSegments(segments);
for (DataSegment segment : segments) {
Assert.assertArrayEquals(mapper.writeValueAsString(segment).getBytes(StandardCharsets.UTF_8), derbyConnector.lookup(derbyConnectorRule.metadataTablesConfigSupplier().get().getSegmentsTable(), "id", "payload", segment.getId().toString()));
}
List<String> segmentIds = segments.stream().map(segment -> segment.getId().toString()).collect(Collectors.toList());
segmentIds.sort(Comparator.naturalOrder());
Assert.assertEquals(segmentIds, retrieveUsedSegmentIds());
// Should not update dataSource metadata.
Assert.assertEquals(0, metadataUpdateCounter.get());
}
use of org.skife.jdbi.v2.Update in project druid by druid-io.
the class JdbcCacheGenerator method lastUpdates.
@Nullable
private Long lastUpdates(CacheScheduler.EntryImpl<JdbcExtractionNamespace> key, JdbcExtractionNamespace namespace) {
final DBI dbi = ensureDBI(key, namespace);
final String table = namespace.getTable();
final String tsColumn = namespace.getTsColumn();
if (tsColumn == null) {
return null;
}
final Timestamp update = dbi.withHandle(handle -> {
final String query = StringUtils.format("SELECT MAX(%s) FROM %s", tsColumn, table);
return handle.createQuery(query).map(TimestampMapper.FIRST).first();
});
return update.getTime();
}
use of org.skife.jdbi.v2.Update in project bgpcep by opendaylight.
the class EvpnRibSupportTest method testBuildMpReachNlriUpdate.
@Test
public void testBuildMpReachNlriUpdate() {
final Update update = RIB_SUPPORT.buildUpdate(createRoutes(EVPN_ROUTES), Collections.emptyList(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes2.class));
}
use of org.skife.jdbi.v2.Update in project bgpcep by opendaylight.
the class BGPSessionImplTest method testBGPSession.
@Test
public void testBGPSession() throws BGPDocumentedException {
this.bgpSession.sessionUp();
assertEquals(State.UP, this.bgpSession.getState());
assertEquals(AS_NUMBER, this.bgpSession.getAsNumber());
assertEquals(BGP_ID, this.bgpSession.getBgpId());
assertEquals(1, this.bgpSession.getAdvertisedTableTypes().size());
Assert.assertEquals(State.UP, this.listener.getState());
this.bgpSession.handleMessage(new UpdateBuilder().build());
assertEquals(1, this.listener.getListMsg().size());
assertTrue(this.listener.getListMsg().get(0) instanceof Update);
this.bgpSession.close();
assertEquals(State.IDLE, this.bgpSession.getState());
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(0) instanceof Notify);
final Notify error = (Notify) this.receivedMsgs.get(0);
assertEquals(BGPError.CEASE.getCode(), error.getErrorCode().shortValue());
assertEquals(BGPError.CEASE.getSubcode(), error.getErrorSubcode().shortValue());
Mockito.verify(this.speakerListener).close();
}
use of org.skife.jdbi.v2.Update in project bgpcep by opendaylight.
the class BGPPeer method prefixesToMpReach.
/**
* Creates MPReach for the prefixes to be handled in the same way as linkstate routes.
*
* @param message Update message containing prefixes in NLRI
* @return MpReachNlri with prefixes from the nlri field
*/
private static MpReachNlri prefixesToMpReach(final Update message) {
final List<Ipv4Prefixes> prefixes = message.getNlri().stream().map(n -> new Ipv4PrefixesBuilder().setPrefix(n.getPrefix()).setPathId(n.getPathId()).build()).collect(Collectors.toList());
final MpReachNlriBuilder b = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build()).build()).build());
if (message.getAttributes() != null) {
b.setCNextHop(message.getAttributes().getCNextHop());
}
return b.build();
}
Aggregations