use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class TetheringClientHandlerTest method setUp.
@Before
public void setUp() throws Exception {
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
CConfiguration conf = CConfiguration.create();
serverHandler = new MockTetheringServerHandler();
serverService = new CommonNettyHttpServiceBuilder(conf, getClass().getSimpleName() + "_server").setHttpHandlers(serverHandler).build();
serverService.start();
serverConfig = ClientConfig.builder().setConnectionConfig(ConnectionConfig.builder().setHostname(serverService.getBindAddress().getHostName()).setPort(serverService.getBindAddress().getPort()).setSSLEnabled(false).build()).build();
cConf.setInt(Constants.Tethering.CONNECTION_INTERVAL, 1);
cConf.setInt(Constants.Tethering.CONNECTION_TIMEOUT_SECONDS, 5);
cConf.set(Constants.INSTANCE_NAME, CLIENT_INSTANCE);
List<Permission> tetheringPermissions = Arrays.asList(InstancePermission.TETHER);
InMemoryAccessController inMemoryAccessController = new InMemoryAccessController();
inMemoryAccessController.grant(Authorizable.fromEntityId(InstanceId.SELF), MASTER_PRINCIPAL, Collections.unmodifiableSet(new HashSet<>(tetheringPermissions)));
ContextAccessEnforcer contextAccessEnforcer = new DefaultContextAccessEnforcer(new AuthenticationTestContext(), inMemoryAccessController);
AuthenticationTestContext.actAsPrincipal(MASTER_PRINCIPAL);
MessagingService messagingService = injector.getInstance(MessagingService.class);
clientService = new CommonNettyHttpServiceBuilder(conf, getClass().getSimpleName() + "_client").setHttpHandlers(new TetheringClientHandler(tetheringStore, contextAccessEnforcer), new TetheringHandler(cConf, tetheringStore, messagingService)).build();
clientService.start();
clientConfig = ClientConfig.builder().setConnectionConfig(ConnectionConfig.builder().setHostname(clientService.getBindAddress().getHostName()).setPort(clientService.getBindAddress().getPort()).setSSLEnabled(false).build()).build();
tetheringAgentService = new TetheringAgentService(cConf, injector.getInstance(TransactionRunner.class), tetheringStore, injector.getInstance(MessagingService.class), injector.getInstance(RemoteAuthenticator.class));
Assert.assertEquals(Service.State.RUNNING, tetheringAgentService.startAndWait());
}
use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class TetheringServerHandlerTest method setup.
@BeforeClass
public static void setup() throws IOException {
cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
topicPrefix = cConf.get(Constants.Tethering.TOPIC_PREFIX);
injector = Guice.createInjector(new ConfigModule(cConf), new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new TransactionExecutorModule(), new InMemoryDiscoveryModule(), new LocalLocationModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new StorageModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new PrivateModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
expose(MetricsCollectionService.class);
}
});
tetheringStore = new TetheringStore(injector.getInstance(TransactionRunner.class));
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
}
use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class DefaultRuntimeJob method createCoreServices.
@VisibleForTesting
Deque<Service> createCoreServices(Injector injector, Arguments systemArgs, Cluster cluster) {
Deque<Service> services = new LinkedList<>();
services.add(injector.getInstance(LogAppenderLoaderService.class));
MessagingService messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
services.add((Service) messagingService);
}
services.add(injector.getInstance(MessagingHttpService.class));
// Metrics need TMS, hence start it after TMS.
MetricsCollectionService metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
services.add(metricsCollectionService);
// Starts the traffic relay if monitoring is done through SSH tunnel
if (injector.getInstance(RuntimeMonitorType.class) == RuntimeMonitorType.SSH) {
services.add(injector.getInstance(TrafficRelayService.class));
}
services.add(injector.getInstance(RuntimeClientService.class));
// Creates a service to emit profile metrics
ProgramRunId programRunId = injector.getInstance(ProgramRunId.class);
ProfileId profileId = SystemArguments.getProfileIdFromArgs(programRunId.getNamespaceId(), systemArgs.asMap()).orElseThrow(() -> new IllegalStateException("Missing profile information for program run " + programRunId));
services.add(new ProfileMetricService(metricsCollectionService, programRunId, profileId, cluster.getNodes().size()));
return services;
}
use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class SupportBundleTestBase 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));
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));
appFabricHealthCheckService = injector.getInstance(HealthCheckService.class);
appFabricHealthCheckService.helper(Constants.AppFabricHealthCheck.APP_FABRIC_HEALTH_CHECK_SERVICE, cConf, Constants.Service.MASTER_SERVICES_BIND_ADDRESS);
appFabricHealthCheckService.startAndWait();
supportBundleInternalService = injector.getInstance(SupportBundleInternalService.class);
supportBundleInternalService.startAndWait();
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);
}
}
}
use of io.cdap.cdap.messaging.MessagingService in project cdap by caskdata.
the class StandaloneMain method startUp.
/**
* Start the service.
*/
public void startUp() throws Exception {
// Workaround for release of file descriptors opened by URLClassLoader - https://issues.cask.co/browse/CDAP-2841
URLConnections.setDefaultUseCaches(false);
ConfigurationLogger.logImportantConfig(cConf);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
// TODO: CDAP-7688, remove next line after the issue is resolved
injector.getInstance(MessagingHttpService.class).startAndWait();
if (txService != null) {
txService.startAndWait();
}
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
metadataStorage.createIndex();
metricsCollectionService.startAndWait();
datasetOpExecutorService.startAndWait();
datasetService.startAndWait();
serviceStore.startAndWait();
remoteExecutionTwillRunnerService.start();
metadataSubscriberService.startAndWait();
// Validate the logging pipeline configuration.
// Do it explicitly as Standalone doesn't have a separate master check phase as the distributed does.
new LogPipelineLoader(cConf).validate();
// It is recommended to initialize log appender after datasetService is started,
// since log appender instantiates a dataset.
logAppenderInitializer.initialize();
runtimeServer.startAndWait();
Service.State state = appFabricServer.startAndWait();
if (state != Service.State.RUNNING) {
throw new Exception("Failed to start Application Fabric");
}
previewHttpServer.startAndWait();
previewRunnerManager.startAndWait();
metricsQueryService.startAndWait();
logQueryService.startAndWait();
router.startAndWait();
if (userInterfaceService != null) {
userInterfaceService.startAndWait();
}
if (SecurityUtil.isManagedSecurity(cConf)) {
externalAuthenticationServer.startAndWait();
}
if (exploreExecutorService != null) {
exploreExecutorService.startAndWait();
}
metadataService.startAndWait();
operationalStatsService.startAndWait();
secureStoreService.startAndWait();
supportBundleInternalService.startAndWait();
appFabricHealthCheckService.startAndWait();
String protocol = sslEnabled ? "https" : "http";
int dashboardPort = sslEnabled ? cConf.getInt(Constants.Dashboard.SSL_BIND_PORT) : cConf.getInt(Constants.Dashboard.BIND_PORT);
System.out.println("CDAP Sandbox started successfully.");
System.out.printf("Connect to the CDAP UI at %s://%s:%d\n", protocol, "localhost", dashboardPort);
}
Aggregations