use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.
the class StreamTailer method main.
public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.out.println(String.format("Usage: java %s [streamName]", StreamTailer.class.getName()));
return;
}
String streamName = args[0];
CConfiguration cConf = CConfiguration.create();
Configuration hConf = new Configuration();
String txClientId = StreamTailer.class.getName();
Injector injector = Guice.createInjector(new ConfigModule(cConf, hConf), new DataFabricModules(txClientId).getDistributedModules(), new DataSetsModules().getDistributedModules(), new LocationRuntimeModule().getDistributedModules(), new ExploreClientModule(), new ViewAdminModules().getDistributedModules(), new StreamAdminModules().getDistributedModules(), new AuthorizationEnforcementModule().getDistributedModules(), new AuthenticationContextModules().getMasterModule(), new NotificationFeedClientModule());
StreamAdmin streamAdmin = injector.getInstance(StreamAdmin.class);
//TODO: get namespace from commandline arguments
StreamId streamId = NamespaceId.DEFAULT.stream(streamName);
StreamConfig streamConfig = streamAdmin.getConfig(streamId);
Location streamLocation = streamConfig.getLocation();
List<Location> eventFiles = Lists.newArrayList();
for (Location partition : streamLocation.list()) {
if (!partition.isDirectory()) {
continue;
}
for (Location file : partition.list()) {
if (StreamFileType.EVENT.isMatched(file.getName())) {
eventFiles.add(file);
}
}
}
int generation = StreamUtils.getGeneration(streamConfig);
MultiLiveStreamFileReader reader = new MultiLiveStreamFileReader(streamConfig, ImmutableList.copyOf(Iterables.transform(eventFiles, createOffsetConverter(generation))));
List<StreamEvent> events = Lists.newArrayList();
while (reader.read(events, 10, 100, TimeUnit.MILLISECONDS) >= 0) {
for (StreamEvent event : events) {
System.out.println(event.getTimestamp() + " " + Charsets.UTF_8.decode(event.getBody()));
}
events.clear();
}
reader.close();
}
use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.
the class InMemoryMetricsTableTest method setup.
@BeforeClass
public static void setup() throws Exception {
Injector injector = Guice.createInjector(new ConfigModule(), new NonCustomLocationUnitTestModule().getModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new DataFabricModules().getInMemoryModules(), new TransactionMetricsModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new PrivateModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
bind(DatasetFramework.class).to(InMemoryDatasetFramework.class);
expose(DatasetFramework.class);
}
});
dsFramework = injector.getInstance(DatasetFramework.class);
}
use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.
the class LevelDBMetricsTableTest method setup.
@BeforeClass
public static void setup() throws Exception {
CConfiguration conf = CConfiguration.create();
conf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
Injector injector = Guice.createInjector(new ConfigModule(conf), new NonCustomLocationUnitTestModule().getModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new DiscoveryRuntimeModule().getStandaloneModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new DataSetsModules().getInMemoryModules(), new DataFabricLevelDBModule(), new TransactionMetricsModule());
dsFramework = injector.getInstance(DatasetFramework.class);
}
use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.
the class LevelDBTableServiceTest method init.
@BeforeClass
public static void init() throws Exception {
CConfiguration conf = CConfiguration.create();
conf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
injector = Guice.createInjector(new ConfigModule(conf), new NonCustomLocationUnitTestModule().getModule(), new DiscoveryRuntimeModule().getStandaloneModules(), new DataSetsModules().getStandaloneModules(), new DataFabricLevelDBModule(), new TransactionMetricsModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getStandaloneModules(), new AuthenticationContextModules().getMasterModule());
service = injector.getInstance(LevelDBTableService.class);
}
use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.
the class ConfiguratorTest method setup.
@BeforeClass
public static void setup() throws IOException {
conf = CConfiguration.create();
conf.set(Constants.CFG_LOCAL_DATA_DIR, TMP_FOLDER.newFolder().getAbsolutePath());
Injector injector = Guice.createInjector(new ConfigModule(conf), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule());
authorizer = injector.getInstance(AuthorizerInstantiator.class).get();
authEnforcer = injector.getInstance(AuthorizationEnforcer.class);
authenticationContext = injector.getInstance(AuthenticationContext.class);
}
Aggregations