org.weakref.jmx.guice.MBeanModule Java Examples
The following examples show how to use
org.weakref.jmx.guice.MBeanModule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhoenixConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) { requireNonNull(requiredConfig, "requiredConfig is null"); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { Bootstrap app = new Bootstrap( new JsonModule(), new MBeanServerModule(), new MBeanModule(), new PhoenixClientModule(catalogName), binder -> { binder.bind(ClassLoader.class).toInstance(PhoenixConnectorFactory.class.getClassLoader()); binder.bind(TypeManager.class).toInstance(context.getTypeManager()); }); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(requiredConfig) .initialize(); return injector.getInstance(PhoenixConnector.class); } }
Example #2
Source File: ElasticsearchConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(catalogName, "catalogName is null"); requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new MBeanModule(), new MBeanServerModule(), new ConnectorObjectNameGeneratorModule(catalogName, "io.prestosql.elasticsearch", "presto.plugin.elasticsearch"), new JsonModule(), new ElasticsearchConnectorModule(), binder -> { binder.bind(TypeManager.class).toInstance(context.getTypeManager()); binder.bind(NodeManager.class).toInstance(context.getNodeManager()); }); Injector injector = app.strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(ElasticsearchConnector.class); }
Example #3
Source File: DbSessionPropertyManagerFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public SessionPropertyConfigurationManager create(Map<String, String> config, SessionPropertyConfigurationManagerContext context) { try { Bootstrap app = new Bootstrap( new MBeanModule(), new MBeanServerModule(), new JsonModule(), new DbSessionPropertyManagerModule()); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(DbSessionPropertyManager.class); } catch (Exception e) { throwIfUnchecked(e); throw new RuntimeException(e); } }
Example #4
Source File: ThriftConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { Bootstrap app = new Bootstrap( new MBeanModule(), new MBeanServerModule(), new ConnectorObjectNameGeneratorModule(catalogName, "io.prestosql.plugin.thrift", "presto.plugin.thrift"), new DriftNettyClientModule(), binder -> { binder.bind(TypeManager.class).toInstance(context.getTypeManager()); }, locationModule, new ThriftModule()); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(ThriftConnector.class); }
Example #5
Source File: CassandraConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new MBeanModule(), new JsonModule(), new CassandraClientModule(), new MBeanServerModule()); Injector injector = app.strictConfig().doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(CassandraConnector.class); }
Example #6
Source File: DbResourceGroupConfigurationManagerFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public ResourceGroupConfigurationManager<?> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) { Bootstrap app = new Bootstrap( new MBeanModule(), new MBeanServerModule(), new JsonModule(), new DbResourceGroupsModule(), new PrefixObjectNameGeneratorModule("io.prestosql.plugin.resourcegroups.db", "presto.plugin.resourcegroups.db"), binder -> binder.bind(String.class).annotatedWith(ForEnvironment.class).toInstance(context.getEnvironment()), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager())); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(DbResourceGroupConfigurationManager.class); }
Example #7
Source File: PrestoProxy.java From presto with Apache License 2.0 | 6 votes |
public static void start(Module... extraModules) { Bootstrap app = new Bootstrap(ImmutableList.<Module>builder() .add(new NodeModule()) .add(new HttpServerModule()) .add(new JsonModule()) .add(new JaxrsModule()) .add(new MBeanModule()) .add(new JmxModule()) .add(new LogJmxModule()) .add(new TraceTokenModule()) .add(new EventModule()) .add(new ProxyModule()) .add(extraModules) .build()); Logger log = Logger.get(PrestoProxy.class); try { app.strictConfig().initialize(); log.info("======== SERVER STARTED ========"); } catch (Throwable t) { log.error(t); System.exit(1); } }
Example #8
Source File: PinotConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(catalogName, "connectorId is null"); requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new JsonModule(), new MBeanModule(), new PinotModule(catalogName, context.getTypeManager(), context.getNodeManager())); Injector injector = app.strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(PinotConnector.class); }
Example #9
Source File: JdbcDiagnosticModule.java From presto with Apache License 2.0 | 5 votes |
@Override public void configure(Binder binder) { binder.install(new MBeanServerModule()); binder.install(new MBeanModule()); newExporter(binder).export(Key.get(JdbcClient.class, StatsCollecting.class)) .as(generator -> generator.generatedNameOf(JdbcClient.class, catalogName)); newExporter(binder).export(Key.get(ConnectionFactory.class, StatsCollecting.class)) .as(generator -> generator.generatedNameOf(ConnectionFactory.class, catalogName)); }
Example #10
Source File: RaptorConnectorFactory.java From presto with Apache License 2.0 | 5 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { Bootstrap app = new Bootstrap( new JsonModule(), new MBeanModule(), new ConnectorObjectNameGeneratorModule(catalogName, "io.prestosql.plugin.raptor.legacy", "presto.plugin.raptor.legacy"), new MBeanServerModule(), binder -> { binder.bind(NodeManager.class).toInstance(context.getNodeManager()); binder.bind(PageSorter.class).toInstance(context.getPageSorter()); binder.bind(TypeManager.class).toInstance(context.getTypeManager()); }, metadataModule, new BackupModule(backupProviders), new StorageModule(), new RaptorModule(catalogName), new RaptorSecurityModule(catalogName)); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(RaptorConnector.class); }
Example #11
Source File: JmxModule.java From digdag with Apache License 2.0 | 5 votes |
@Override public void configure() { install(new MBeanModule()); binder().bind(MBeanServer.class).toInstance(ManagementFactory.getPlatformMBeanServer()); binder().bind(JmxAgent.class).asEagerSingleton(); }
Example #12
Source File: InternalIcebergConnectorFactory.java From presto with Apache License 2.0 | 4 votes |
public static Connector createConnector(String catalogName, Map<String, String> config, ConnectorContext context, Optional<HiveMetastore> metastore) { ClassLoader classLoader = InternalIcebergConnectorFactory.class.getClassLoader(); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { Bootstrap app = new Bootstrap( new EventModule(), new MBeanModule(), new JsonModule(), new IcebergModule(), new HiveS3Module(), new HiveAuthenticationModule(), new HiveMetastoreModule(metastore), new MBeanServerModule(), binder -> { binder.bind(NodeVersion.class).toInstance(new NodeVersion(context.getNodeManager().getCurrentNode().getVersion())); binder.bind(NodeManager.class).toInstance(context.getNodeManager()); binder.bind(TypeManager.class).toInstance(context.getTypeManager()); binder.bind(PageIndexerFactory.class).toInstance(context.getPageIndexerFactory()); binder.bind(CatalogName.class).toInstance(new CatalogName(catalogName)); }); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class); IcebergTransactionManager transactionManager = injector.getInstance(IcebergTransactionManager.class); IcebergMetadataFactory metadataFactory = injector.getInstance(IcebergMetadataFactory.class); ConnectorSplitManager splitManager = injector.getInstance(ConnectorSplitManager.class); ConnectorPageSourceProvider connectorPageSource = injector.getInstance(ConnectorPageSourceProvider.class); ConnectorPageSinkProvider pageSinkProvider = injector.getInstance(ConnectorPageSinkProvider.class); ConnectorNodePartitioningProvider connectorDistributionProvider = injector.getInstance(ConnectorNodePartitioningProvider.class); IcebergSessionProperties icebergSessionProperties = injector.getInstance(IcebergSessionProperties.class); IcebergTableProperties icebergTableProperties = injector.getInstance(IcebergTableProperties.class); return new IcebergConnector( lifeCycleManager, transactionManager, metadataFactory, new ClassLoaderSafeConnectorSplitManager(splitManager, classLoader), new ClassLoaderSafeConnectorPageSourceProvider(connectorPageSource, classLoader), new ClassLoaderSafeConnectorPageSinkProvider(pageSinkProvider, classLoader), new ClassLoaderSafeNodePartitioningProvider(connectorDistributionProvider, classLoader), ImmutableSet.of(), icebergSessionProperties.getSessionProperties(), IcebergSchemaProperties.SCHEMA_PROPERTIES, icebergTableProperties.getTableProperties(), new AllowAllAccessControl()); } }
Example #13
Source File: InternalHiveConnectorFactory.java From presto with Apache License 2.0 | 4 votes |
public static Connector createConnector(String catalogName, Map<String, String> config, ConnectorContext context, Module module, Optional<HiveMetastore> metastore) { requireNonNull(config, "config is null"); ClassLoader classLoader = InternalHiveConnectorFactory.class.getClassLoader(); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { Bootstrap app = new Bootstrap( new EventModule(), new MBeanModule(), new ConnectorObjectNameGeneratorModule(catalogName, "io.prestosql.plugin.hive", "presto.plugin.hive"), new JsonModule(), new HiveModule(), new HiveS3Module(), new HiveGcsModule(), new HiveAzureModule(), installModuleIf(RubixEnabledConfig.class, RubixEnabledConfig::isCacheEnabled, new RubixModule()), new HiveMetastoreModule(metastore), new HiveSecurityModule(catalogName), new HiveAuthenticationModule(), new HiveProcedureModule(), new MBeanServerModule(), binder -> { binder.bind(NodeVersion.class).toInstance(new NodeVersion(context.getNodeManager().getCurrentNode().getVersion())); binder.bind(NodeManager.class).toInstance(context.getNodeManager()); binder.bind(VersionEmbedder.class).toInstance(context.getVersionEmbedder()); binder.bind(TypeManager.class).toInstance(context.getTypeManager()); binder.bind(PageIndexerFactory.class).toInstance(context.getPageIndexerFactory()); binder.bind(PageSorter.class).toInstance(context.getPageSorter()); binder.bind(CatalogName.class).toInstance(new CatalogName(catalogName)); }, binder -> newSetBinder(binder, EventListener.class), module); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class); HiveMetadataFactory metadataFactory = injector.getInstance(HiveMetadataFactory.class); HiveTransactionManager transactionManager = injector.getInstance(HiveTransactionManager.class); ConnectorSplitManager splitManager = injector.getInstance(ConnectorSplitManager.class); ConnectorPageSourceProvider connectorPageSource = injector.getInstance(ConnectorPageSourceProvider.class); ConnectorPageSinkProvider pageSinkProvider = injector.getInstance(ConnectorPageSinkProvider.class); ConnectorNodePartitioningProvider connectorDistributionProvider = injector.getInstance(ConnectorNodePartitioningProvider.class); HiveSessionProperties hiveSessionProperties = injector.getInstance(HiveSessionProperties.class); HiveTableProperties hiveTableProperties = injector.getInstance(HiveTableProperties.class); HiveAnalyzeProperties hiveAnalyzeProperties = injector.getInstance(HiveAnalyzeProperties.class); ConnectorAccessControl accessControl = new ClassLoaderSafeConnectorAccessControl( new SystemTableAwareAccessControl(injector.getInstance(ConnectorAccessControl.class)), classLoader); Set<Procedure> procedures = injector.getInstance(Key.get(new TypeLiteral<Set<Procedure>>() {})); Set<SystemTable> systemTables = injector.getInstance(Key.get(new TypeLiteral<Set<SystemTable>>() {})); Set<EventListener> eventListeners = injector.getInstance(Key.get(new TypeLiteral<Set<EventListener>>() {})) .stream() .map(listener -> new ClassLoaderSafeEventListener(listener, classLoader)) .collect(toImmutableSet()); return new HiveConnector( lifeCycleManager, metadataFactory, transactionManager, new ClassLoaderSafeConnectorSplitManager(splitManager, classLoader), new ClassLoaderSafeConnectorPageSourceProvider(connectorPageSource, classLoader), new ClassLoaderSafeConnectorPageSinkProvider(pageSinkProvider, classLoader), new ClassLoaderSafeNodePartitioningProvider(connectorDistributionProvider, classLoader), systemTables, procedures, eventListeners, hiveSessionProperties.getSessionProperties(), HiveSchemaProperties.SCHEMA_PROPERTIES, hiveTableProperties.getTableProperties(), hiveAnalyzeProperties.getAnalyzeProperties(), accessControl, classLoader); } }
Example #14
Source File: ClientTestUtils.java From drift with Apache License 2.0 | 4 votes |
public static int logDriftClientBinder( HostAndPort address, String headerValue, List<DriftLogEntry> entries, Module transportModule, List<MethodInvocationFilter> filters, Transport transport, Protocol protocol, boolean secure) { // filters are not supported in the binder yet if (!filters.isEmpty()) { return 0; } AddressSelector<?> addressSelector = context -> Optional.of(() -> address); Bootstrap app = new Bootstrap( new MBeanModule(), new TestingJmxModule(), transportModule, binder -> driftClientBinder(binder).bindDriftClient(DriftScribe.class) .withAddressSelector(addressSelector) .withMethodInvocationFilter(staticFilterBinder(filters)), binder -> driftClientBinder(binder).bindDriftClient(DriftScribe.class, CustomClient.class) .withAddressSelector(addressSelector) .withMethodInvocationFilter(staticFilterBinder(filters)), binder -> binder.bind(ScribeUser.class).in(Scopes.SINGLETON)); LifeCycleManager lifeCycleManager = null; try { app.setRequiredConfigurationProperties(ImmutableMap.<String, String>builder() .put("scribe.thrift.client.transport", transport.toString()) .put("scribe.CustomClient.thrift.client.transport", transport.toString()) .put("scribe.thrift.client.protocol", protocol.toString()) .put("scribe.CustomClient.thrift.client.protocol", protocol.toString()) .build()); // Nifty ssl configuration is for all clients, where Apache and Netty are configured per client app.setOptionalConfigurationProperties(ImmutableMap.<String, String>builder() .put("thrift.client.ssl.enabled", String.valueOf(secure)) .put("scribe.thrift.client.ssl.enabled", String.valueOf(secure)) .put("scribe.CustomClient.thrift.client.ssl.enabled", String.valueOf(secure)) .put("thrift.client.ssl.trust-certificate", getCertificateChainFile().getAbsolutePath()) .put("scribe.thrift.client.ssl.trust-certificate", getCertificateChainFile().getAbsolutePath()) .put("scribe.CustomClient.thrift.client.ssl.trust-certificate", getCertificateChainFile().getAbsolutePath()) .build()); Injector injector = app .strictConfig() .doNotInitializeLogging() .initialize(); lifeCycleManager = injector.getInstance(LifeCycleManager.class); DriftScribe scribe = injector.getInstance(DriftScribe.class); ScribeUser user = injector.getInstance(ScribeUser.class); assertEquals(scribe.log(headerValue, entries), DRIFT_OK); assertEquals(user.getClient().log(headerValue, entries), DRIFT_OK); assertEquals(user.getClientCustom().log(headerValue, entries), DRIFT_OK); assertEquals(user.getFactory().get().log(headerValue, entries), DRIFT_OK); assertEquals(user.getFactoryCustom().get().log(headerValue, entries), DRIFT_OK); assertSame(scribe, user.getClient()); assertNotSame(user.getClient(), user.getClientCustom()); assertNotSame(user.getFactory(), user.getFactoryCustom()); } catch (Exception e) { throw new RuntimeException(e); } finally { if (lifeCycleManager != null) { try { lifeCycleManager.stop(); } catch (Exception ignored) { } } } return 5; }