use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class AppFabricTestBase method initializeAndStartServices.
protected static void initializeAndStartServices(CConfiguration cConf, Module overrides) throws Exception {
injector = Guice.createInjector(Modules.override(new AppFabricTestModule(cConf, null)).with(overrides));
int connectionTimeout = cConf.getInt(Constants.HTTP_CLIENT_CONNECTION_TIMEOUT_MS);
int readTimeout = cConf.getInt(Constants.HTTP_CLIENT_READ_TIMEOUT_MS);
httpRequestConfig = new HttpRequestConfig(connectionTimeout, readTimeout, false);
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
metadataStorage = injector.getInstance(MetadataStorage.class);
metadataStorage.createIndex();
dsOpService = injector.getInstance(DatasetOpExecutorService.class);
dsOpService.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
DiscoveryServiceClient discoveryClient = injector.getInstance(DiscoveryServiceClient.class);
appFabricEndpointStrategy = new RandomEndpointStrategy(() -> discoveryClient.discover(Constants.Service.APP_FABRIC_HTTP));
txClient = injector.getInstance(TransactionSystemClient.class);
metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
metricsCollectionService.startAndWait();
serviceStore = injector.getInstance(ServiceStore.class);
serviceStore.startAndWait();
metadataService = injector.getInstance(MetadataService.class);
metadataService.startAndWait();
metadataSubscriberService = injector.getInstance(MetadataSubscriberService.class);
metadataSubscriberService.startAndWait();
logQueryService = injector.getInstance(LogQueryService.class);
logQueryService.startAndWait();
locationFactory = getInjector().getInstance(LocationFactory.class);
datasetClient = new DatasetClient(getClientConfig(discoveryClient, Constants.Service.DATASET_MANAGER));
remoteClientFactory = new RemoteClientFactory(discoveryClient, new DefaultInternalAuthenticator(new AuthenticationTestContext()));
metadataClient = new MetadataClient(getClientConfig(discoveryClient, Constants.Service.METADATA_SERVICE));
metadataServiceClient = new DefaultMetadataServiceClient(remoteClientFactory);
metricStore = injector.getInstance(MetricStore.class);
Scheduler programScheduler = injector.getInstance(Scheduler.class);
// Wait for the scheduler to be functional.
if (programScheduler instanceof CoreSchedulerService) {
try {
((CoreSchedulerService) programScheduler).waitUntilFunctional(10, TimeUnit.SECONDS);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
createNamespaces();
}
use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class GatewayTestBase method startGateway.
public static Injector startGateway(final CConfiguration conf) throws Exception {
// Set up our Guice injections
injector = Guice.createInjector(Modules.override(new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@Named(Constants.Router.ADDRESS)
public final InetAddress providesHostname(CConfiguration cConf) {
return Networks.resolve(cConf.get(Constants.Router.ADDRESS), new InetSocketAddress("localhost", 0).getAddress());
}
}, new CoreSecurityRuntimeModule().getInMemoryModules(), new ExternalAuthenticationModule(), new AppFabricTestModule(conf)).with(new AbstractModule() {
@Override
protected void configure() {
// It's a bit hacky to add it here. Need to refactor these
// bindings out as it overlaps with
// AppFabricServiceModule
bind(LogReader.class).to(MockLogReader.class).in(Scopes.SINGLETON);
bind(PermissionManager.class).to(NoOpAccessController.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
}
}));
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
txService = injector.getInstance(TransactionManager.class);
txService.startAndWait();
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
metadataStorage = injector.getInstance(MetadataStorage.class);
metadataStorage.createIndex();
metadataService = injector.getInstance(MetadataService.class);
metadataService.startAndWait();
dsOpService = injector.getInstance(DatasetOpExecutorService.class);
dsOpService.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
logQueryService = injector.getInstance(LogQueryService.class);
logQueryService.startAndWait();
metricsQueryService = injector.getInstance(MetricsQueryService.class);
metricsQueryService.startAndWait();
metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
metricsCollectionService.startAndWait();
namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
namespaceAdmin.create(TEST_NAMESPACE_META1);
namespaceAdmin.create(TEST_NAMESPACE_META2);
// Restart handlers to check if they are resilient across restarts.
router = injector.getInstance(NettyRouter.class);
router.startAndWait();
port = router.getBoundAddress().orElseThrow(IllegalStateException::new).getPort();
return injector;
}
use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class GatewayTestBase method stopGateway.
public static void stopGateway(CConfiguration conf) throws Exception {
namespaceAdmin.delete(new NamespaceId(TEST_NAMESPACE1));
namespaceAdmin.delete(new NamespaceId(TEST_NAMESPACE2));
namespaceAdmin.delete(NamespaceId.DEFAULT);
appFabricServer.stopAndWait();
metricsCollectionService.stopAndWait();
metricsQueryService.stopAndWait();
logQueryService.stopAndWait();
router.stopAndWait();
datasetService.stopAndWait();
dsOpService.stopAndWait();
metadataService.stopAndWait();
Closeables.closeQuietly(metadataStorage);
txService.stopAndWait();
if (messagingService instanceof Service) {
((Service) messagingService).stopAndWait();
}
conf.clear();
}
use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class MetricsAdminSubscriberServiceTest method init.
@BeforeClass
public static void init() throws IOException {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
// Shorten delay to speed up test
cConf.setLong(Constants.Metrics.ADMIN_POLL_DELAY_MILLIS, 100L);
injector = Guice.createInjector(new ConfigModule(cConf), new IOModule(), new InMemoryDiscoveryModule(), new MessagingServerRuntimeModule().getStandaloneModules(), new SystemDatasetRuntimeModule().getStandaloneModules(), // distributed mode. It requires bindings that are too cumbersome to construct them one by one.
new PrivateModule() {
@Override
protected void configure() {
install(new MetricsHandlerModule());
expose(MetricsQueryService.class);
install(new MetricsStoreModule());
bind(MetricsCollectionService.class).to(LocalMetricsCollectionService.class).in(Scopes.SINGLETON);
expose(MetricsCollectionService.class);
// Bind the RemoteMetricsSystemClient for testing.
bind(MetricsSystemClient.class).to(DirectMetricsSystemClient.class);
expose(MetricsSystemClient.class);
// Bind the admin subscriber
bind(MetricsAdminSubscriberService.class).in(Scopes.SINGLETON);
expose(MetricsAdminSubscriberService.class);
}
});
messagingService = injector.getInstance(MessagingService.class);
metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
metricsQueryService = injector.getInstance(MetricsQueryService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
metricsCollectionService.startAndWait();
metricsQueryService.startAndWait();
}
use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class MetricsTestBase method init.
@Before
public void init() throws IOException, UnsupportedTypeException {
cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.set(Constants.Metrics.TOPIC_PREFIX, TOPIC_PREFIX);
cConf.setInt(Constants.Metrics.MESSAGING_TOPIC_NUM, 10);
cConf.setInt(Constants.Metrics.QUEUE_SIZE, 1000);
// Set it to really short delay for faster test
cConf.setLong(Constants.Metrics.PROCESSOR_MAX_DELAY_MS, 5);
injector = Guice.createInjector(getModules());
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
metricValueType = TypeToken.of(MetricValues.class);
schema = new ReflectionSchemaGenerator().generate(metricValueType.getType());
recordWriter = new ASMDatumWriterFactory(new ASMFieldAccessorFactory()).create(metricValueType, schema);
}
Aggregations