@Override public void configure(Binder binder) { binder.bind(TypeManager.class).toInstance(typeManager); binder.bind(ExampleConnector.class).in(Scopes.SINGLETON); binder.bind(ExampleConnectorId.class).toInstance(new ExampleConnectorId(connectorId)); binder.bind(ExampleMetadata.class).in(Scopes.SINGLETON); binder.bind(ExampleClient.class).in(Scopes.SINGLETON); binder.bind(ExampleSplitManager.class).in(Scopes.SINGLETON); binder.bind(ExampleRecordSetProvider.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(ExampleConfig.class); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); jsonCodecBinder(binder).bindMapJsonCodec(String.class, listJsonCodec(ExampleTable.class)); }
@Override public void configure(Binder binder) { // Add appender to Log4J root logger JulAppender appender = new JulAppender(); //create appender appender.setLayout(new PatternLayout("%d %-5p %c - %m%n")); appender.setThreshold(Level.INFO); appender.activateOptions(); org.apache.log4j.Logger.getRootLogger().addAppender(appender); binder.bind(TypeManager.class).toInstance(typeManager); binder.bind(AccumuloConnector.class).in(Scopes.SINGLETON); binder.bind(AccumuloConnectorId.class).toInstance(new AccumuloConnectorId(connectorId)); binder.bind(AccumuloMetadata.class).in(Scopes.SINGLETON); binder.bind(AccumuloMetadataFactory.class).in(Scopes.SINGLETON); binder.bind(AccumuloClient.class).in(Scopes.SINGLETON); binder.bind(AccumuloSplitManager.class).in(Scopes.SINGLETON); binder.bind(AccumuloRecordSetProvider.class).in(Scopes.SINGLETON); binder.bind(AccumuloPageSinkProvider.class).in(Scopes.SINGLETON); binder.bind(AccumuloHandleResolver.class).in(Scopes.SINGLETON); binder.bind(AccumuloSessionProperties.class).in(Scopes.SINGLETON); binder.bind(AccumuloTableProperties.class).in(Scopes.SINGLETON); binder.bind(ZooKeeperMetadataManager.class).in(Scopes.SINGLETON); binder.bind(AccumuloTableManager.class).in(Scopes.SINGLETON); binder.bind(IndexLookup.class).in(Scopes.SINGLETON); binder.bind(ColumnCardinalityCache.class).in(Scopes.SINGLETON); binder.bind(Connector.class).toProvider(ConnectorProvider.class); configBinder(binder).bindConfig(AccumuloConfig.class); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); jsonCodecBinder(binder).bindMapJsonCodec(String.class, JsonCodec.listJsonCodec(AccumuloTable.class)); }
@Test public void testGetAllNodes() { List<Stats> nodes = client.execute( prepareGet().setUri(server.resolve("/v1/node")).build(), createJsonResponseHandler(listJsonCodec(Stats.class))); // we only have one node and the list never contains the current node assertTrue(nodes.isEmpty()); }
@Test public void testGetQueryStateInfosForUserNoResult() { List<QueryStateInfo> infos = client.execute( prepareGet().setUri(server.resolve("/v1/queryState?user=user3")).build(), createJsonResponseHandler(listJsonCodec(QueryStateInfo.class))); assertTrue(infos.isEmpty()); }
@Test public void testGetFailedNodes() { List<Stats> nodes = client.execute( prepareGet().setUri(server.resolve("/v1/node/failed")).build(), createJsonResponseHandler(listJsonCodec(Stats.class))); assertTrue(nodes.isEmpty()); } }
@Test public void testGetQueryStateInfosForUser() { List<QueryStateInfo> infos = client.execute( prepareGet().setUri(server.resolve("/v1/queryState?user=user2")).build(), createJsonResponseHandler(listJsonCodec(QueryStateInfo.class))); assertEquals(infos.size(), 1); }
@Test public void testGetAllQueryStateInfos() { List<QueryStateInfo> infos = client.execute( prepareGet().setUri(server.resolve("/v1/queryState")).build(), createJsonResponseHandler(listJsonCodec(QueryStateInfo.class))); assertEquals(infos.size(), 2); }
private List<BasicQueryInfo> getQueryInfos(String path) { Request request = prepareGet().setUri(server.resolve(path)).build(); return client.execute(request, createJsonResponseHandler(listJsonCodec(BasicQueryInfo.class))); }
CassandraSession session = new NativeCassandraSession( "EmbeddedCassandra", JsonCodec.listJsonCodec(ExtraColumnMetadata.class), cluster, new Duration(1, MINUTES));
@BeforeClass public void setup() { Request request1 = preparePost() .setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/statement").build()) .setBodyGenerator(createStaticBodyGenerator(LONG_LASTING_QUERY, UTF_8)) .setHeader(PRESTO_USER, "user1") .build(); queryResults = client.execute(request1, createJsonResponseHandler(QUERY_RESULTS_JSON_CODEC)); client.execute(prepareGet().setUri(queryResults.getNextUri()).build(), createJsonResponseHandler(QUERY_RESULTS_JSON_CODEC)); Request request2 = preparePost() .setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/statement").build()) .setBodyGenerator(createStaticBodyGenerator(LONG_LASTING_QUERY, UTF_8)) .setHeader(PRESTO_USER, "user2") .build(); QueryResults queryResults2 = client.execute(request2, createJsonResponseHandler(jsonCodec(QueryResults.class))); client.execute(prepareGet().setUri(queryResults2.getNextUri()).build(), createJsonResponseHandler(QUERY_RESULTS_JSON_CODEC)); // queries are started in the background, so they may not all be immediately visible while (true) { List<BasicQueryInfo> queryInfos = client.execute( prepareGet().setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/query").build()).build(), createJsonResponseHandler(listJsonCodec(BasicQueryInfo.class))); if ((queryInfos.size() == 2) && queryInfos.stream().allMatch(info -> info.getState() == RUNNING)) { break; } } }
@Test public void testImmutableListJsonCodec() throws Exception { JsonCodec<List<ImmutablePerson>> jsonCodec = listJsonCodec(ImmutablePerson.class); ImmutablePerson.validatePersonListJsonCodec(jsonCodec); }
@Test public void testListJsonCodec() throws Exception { JsonCodec<List<Person>> jsonCodec = listJsonCodec(Person.class); Person.validatePersonListJsonCodec(jsonCodec); }
@Test public void testListJsonCodec() throws Exception { JsonCodec<List<Person>> jsonCodec = listJsonCodec(Person.class); Person.validatePersonListJsonCodec(jsonCodec); }
@Test public void testListJsonCodecFromJsonCodec() throws Exception { JsonCodec<List<Person>> jsonCodec = listJsonCodec(jsonCodec(Person.class)); Person.validatePersonListJsonCodec(jsonCodec); }
@Test public void testImmutableListJsonCodecFromJsonCodec() throws Exception { JsonCodec<List<ImmutablePerson>> jsonCodec = listJsonCodec(jsonCodec(ImmutablePerson.class)); ImmutablePerson.validatePersonListJsonCodec(jsonCodec); }
@Test public void testImmutableListJsonCodecFromJsonCodec() throws Exception { JsonCodec<List<ImmutablePerson>> jsonCodec = listJsonCodec(jsonCodec(ImmutablePerson.class)); ImmutablePerson.validatePersonListJsonCodec(jsonCodec); }
@Test public void testListJsonCodecFromJsonCodec() throws Exception { JsonCodec<List<Person>> jsonCodec = listJsonCodec(jsonCodec(Person.class)); Person.validatePersonListJsonCodec(jsonCodec); }
@Test public void testToJsonWithLengthLimitComplex() { JsonCodec<List<ImmutablePerson>> jsonCodec = listJsonCodec(jsonCodec(ImmutablePerson.class)); ImmutablePerson person = new ImmutablePerson(Strings.repeat("a", 1000), false); List<ImmutablePerson> people = Collections.nCopies(10, person); assertFalse(jsonCodec.toJsonWithLengthLimit(people, 0).isPresent()); assertFalse(jsonCodec.toJsonWithLengthLimit(people, 5000).isPresent()); assertFalse(jsonCodec.toJsonWithLengthLimit(people, 10381).isPresent()); assertTrue(jsonCodec.toJsonWithLengthLimit(people, 10382).isPresent()); } }
@Test public void testGetAllQueryStateInfos() { List<QueryStateInfo> infos = client.execute( prepareGet().setUri(server.resolve("/v1/queryState")).build(), createJsonResponseHandler(listJsonCodec(QueryStateInfo.class))); assertEquals(infos.size(), 2); }
@Override protected DynamicStore initializeStore(DiscoveryConfig config, Supplier<DateTime> timeSupplier) { RemoteStore dummy = new RemoteStore() { public void put(Entry entry) { } }; DistributedStore distributedStore = new DistributedStore("dynamic", new InMemoryStore(new ConflictResolver()), dummy, new StoreConfig(), timeSupplier); return new ReplicatedDynamicStore(distributedStore, config, listJsonCodec(Service.class)); } }