当前位置: 首页>>代码示例>>Java>>正文


Java JsonModule类代码示例

本文整理汇总了Java中io.airlift.json.JsonModule的典型用法代码示例。如果您正苦于以下问题:Java JsonModule类的具体用法?Java JsonModule怎么用?Java JsonModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JsonModule类属于io.airlift.json包,在下文中一共展示了JsonModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new HDFSModule(connectorId, context.getTypeManager())
        );

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .initialize();

        return injector.getInstance(HDFSConnector.class);
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:dbiir,项目名称:paraflow,代码行数:25,代码来源:HDFSConnectorFactory.java

示例2: create

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public Connector create(final String connectorId, Map<String, String> requiredConfig)
{
    requireNonNull(requiredConfig, "requiredConfig is null");
    requireNonNull(optionalConfig, "optionalConfig is null");

    try {
        // A plugin is not required to use Guice; it is just very convenient
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new ExampleModule(connectorId, typeManager));

    Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(requiredConfig)
                .setOptionalConfigurationProperties(optionalConfig)
                .initialize();

        return injector.getInstance(ExampleConnector.class);
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:ExampleConnectorFactory.java

示例3: create

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public Connector create(final String connectorId, Map<String, String> requiredConfig) {
    checkNotNull(requiredConfig, "requiredConfig is null");
    checkNotNull(optionalConfig, "optionalConfig is null");

    try {
        // A plugin is not required to use Guice; it is just very convenient
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new RiakModule(connectorId, typeManager));

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(requiredConfig)
                .setOptionalConfigurationProperties(optionalConfig)
                .initialize();

        return injector.getInstance(RiakConnector.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:kuenishi,项目名称:presto-riak,代码行数:24,代码来源:RiakConnectorFactory.java

示例4: main

import io.airlift.json.JsonModule; //导入依赖的package包/类
public static void main(String[] args)
        throws Exception
{
    if (System.getProperty("config", null) == null) {
        System.setProperty("config", "etc/agent.properties");
    }

    Bootstrap bootstrap = new Bootstrap(
            new NodeModule(),
            new DiscoveryModule(),
            new HttpServerModule(),
            new JsonModule(),
            new JaxrsModule(true), // requireExplicitBindings = true
            new HttpEventModule(),
            new JsonReaderModule(false),
            new DynamicAnnouncementModule(),
            new AgentServerModule()
    );

    try {
        Injector injector = bootstrap.strictConfig().initialize();
        injector.getInstance(Announcer.class).start();
    }
    catch (Exception e) {
        LOG.error(e, "Error starting server");
    }
}
 
开发者ID:prestodb,项目名称:presto-manager,代码行数:28,代码来源:AgentServer.java

示例5: main

import io.airlift.json.JsonModule; //导入依赖的package包/类
public static void main(String[] args)
        throws Exception
{
    if (System.getProperty("config", null) == null) {
        System.setProperty("config", "etc/controller.properties");
    }

    Bootstrap bootstrap = new Bootstrap(
            new NodeModule(),
            new DiscoveryModule(),
            new DiscoveryServerModule(),
            new HttpEventModule(),
            new HttpServerModule(),
            new JsonModule(),
            new JaxrsModule(true), // requireExplicitBindings = true'
            new JmxModule(),
            new MBeanModule(),
            new JsonReaderModule(false),
            new ControllerServerModule()
    );

    try {
        bootstrap.strictConfig().initialize();
    }
    catch (Exception e) {
        LOG.error(e, "Error starting server");
    }
}
 
开发者ID:prestodb,项目名称:presto-manager,代码行数:29,代码来源:ControllerServer.java

示例6: create

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config)
{
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new KafkaConnectorModule(),
                binder -> {
                    binder.bind(KafkaConnectorId.class).toInstance(new KafkaConnectorId(connectorId));
                    binder.bind(TypeManager.class).toInstance(typeManager);
                    binder.bind(NodeManager.class).toInstance(nodeManager);

                    if (tableDescriptionSupplier.isPresent()) {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KafkaTopicDescription>>>() {}).toInstance(tableDescriptionSupplier.get());
                    }
                    else {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KafkaTopicDescription>>>() {}).to(KafkaTableDescriptionSupplier.class).in(Scopes.SINGLETON);
                    }
                }
        );

        Injector injector = app.strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .setOptionalConfigurationProperties(optionalConfig)
                .initialize();

        return injector.getInstance(KafkaConnector.class);
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:37,代码来源:KafkaConnectorFactory.java

示例7: create

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config)
{
    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new MBeanModule(),
                binder -> {
                    CurrentNodeId currentNodeId = new CurrentNodeId(nodeManager.getCurrentNode().getNodeIdentifier());
                    MBeanServer mbeanServer = new RebindSafeMBeanServer(getPlatformMBeanServer());

                    binder.bind(MBeanServer.class).toInstance(mbeanServer);
                    binder.bind(CurrentNodeId.class).toInstance(currentNodeId);
                    binder.bind(NodeManager.class).toInstance(nodeManager);
                    binder.bind(PageSorter.class).toInstance(pageSorter);
                    binder.bind(BlockEncodingSerde.class).toInstance(blockEncodingSerde);
                    binder.bind(TypeManager.class).toInstance(typeManager);
                },
                metadataModule,
                new BackupModule(backupProviders),
                new StorageModule(connectorId),
                new RaptorModule(connectorId));

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .setOptionalConfigurationProperties(optionalConfig)
                .initialize();

        return injector.getInstance(RaptorConnector.class);
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:37,代码来源:RaptorConnectorFactory.java

示例8: create

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config)
{
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new RedisConnectorModule(),
                binder -> {
                    binder.bind(RedisConnectorId.class).toInstance(new RedisConnectorId(connectorId));
                    binder.bind(TypeManager.class).toInstance(typeManager);
                    binder.bind(NodeManager.class).toInstance(nodeManager);

                    if (tableDescriptionSupplier.isPresent()) {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, RedisTableDescription>>>() {}).toInstance(tableDescriptionSupplier.get());
                    }
                    else {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, RedisTableDescription>>>() {})
                                .to(RedisTableDescriptionSupplier.class)
                                .in(Scopes.SINGLETON);
                    }
                }
        );

        Injector injector = app.strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .setOptionalConfigurationProperties(optionalConfig)
                .initialize();

        return injector.getInstance(RedisConnector.class);
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:39,代码来源:RedisConnectorFactory.java

示例9: TestingDiscoveryServer

import io.airlift.json.JsonModule; //导入依赖的package包/类
public TestingDiscoveryServer(String environment)
        throws Exception
{
    tempDir = Files.createTempDir();

    Map<String, String> serverProperties = ImmutableMap.<String, String>builder()
            .put("static.db.location", tempDir.getAbsolutePath())
            .put("discovery.store-cache-ttl", "0ms")
            .build();

    Bootstrap app = new Bootstrap(
            new MBeanModule(),
            new TestingNodeModule(environment),
            new TestingHttpServerModule(),
            new JsonModule(),
            new JaxrsModule(true),
            new DiscoveryServerModule(),
            new DiscoveryModule(),
            new TestingJmxModule());

    Injector injector = app
            .strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(serverProperties)
            .initialize();

    lifeCycleManager = injector.getInstance(LifeCycleManager.class);

    server = injector.getInstance(TestingHttpServer.class);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:31,代码来源:TestingDiscoveryServer.java

示例10: startUp

import io.airlift.json.JsonModule; //导入依赖的package包/类
@BeforeMethod
public void startUp()
{
    Injector injector = Guice.createInjector(new JsonModule(), new HandleJsonModule());

    objectMapper = injector.getInstance(ObjectMapper.class);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:8,代码来源:TestInformationSchemaTableHandle.java

示例11: create

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config)
{
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new MBeanModule(),
                new JsonModule(),
                new CassandraClientModule(connectorId),
                new Module()
                {
                    @Override
                    public void configure(Binder binder)
                    {
                        MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
                        binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(platformMBeanServer));
                    }
                });

        Injector injector = app.strictConfig().doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .setOptionalConfigurationProperties(optionalConfig).initialize();

        return injector.getInstance(CassandraConnector.class);
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:31,代码来源:CassandraConnectorFactory.java

示例12: run

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public void run()
{
    verifyJvmRequirements();
    verifySystemTimeIsReasonable();

    Logger log = Logger.get(PrestoServer.class);

    ImmutableList.Builder<Module> modules = ImmutableList.builder();
    modules.add(
            new NodeModule(),
            new DiscoveryModule(),
            new HttpServerModule(),
            new JsonModule(),
            new JaxrsModule(true),
            new MBeanModule(),
            new JmxModule(),
            new JmxHttpModule(),
            new LogJmxModule(),
            new TraceTokenModule(),
            new JsonEventModule(),
            new HttpEventModule(),
            new EmbeddedDiscoveryModule(),
            new ServerSecurityModule(),
            new AccessControlModule(),
            new ServerMainModule(sqlParserOptions),
            new GracefulShutdownModule(),
            installModuleIf(
                    NodeSchedulerConfig.class,
                    config -> LEGACY_NETWORK_TOPOLOGY.equalsIgnoreCase(config.getNetworkTopology()),
                    binder -> binder.bind(NetworkTopology.class).to(LegacyNetworkTopology.class).in(Scopes.SINGLETON)),
            installModuleIf(
                    NodeSchedulerConfig.class,
                    config -> "flat".equalsIgnoreCase(config.getNetworkTopology()),
                    binder -> binder.bind(NetworkTopology.class).to(FlatNetworkTopology.class).in(Scopes.SINGLETON))

    );

    modules.addAll(getAdditionalModules());

    Bootstrap app = new Bootstrap(modules.build());

    try {
        Injector injector = app.strictConfig().initialize();

        injector.getInstance(PluginManager.class).loadPlugins();

        injector.getInstance(CatalogManager.class).loadCatalogs();

        // TODO: remove this huge hack
        updateDatasources(
                injector.getInstance(Announcer.class),
                injector.getInstance(Metadata.class),
                injector.getInstance(ServerConfig.class),
                injector.getInstance(NodeSchedulerConfig.class));

        injector.getInstance(AccessControlManager.class).loadSystemAccessControl();

        injector.getInstance(Announcer.class).start();

        log.info("======== SERVER STARTED ========");
    }
    catch (Throwable e) {
        log.error(e);
        System.exit(1);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:68,代码来源:PrestoServer.java

示例13: testExcludesCurrentNode

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Test
public void testExcludesCurrentNode()
        throws Exception
{
    Bootstrap app = new Bootstrap(
            new TestingNodeModule(),
            new TestingJmxModule(),
            new TestingDiscoveryModule(),
            new TestingHttpServerModule(),
            new TraceTokenModule(),
            new JsonModule(),
            new JaxrsModule(true),
            new FailureDetectorModule(),
            new Module()
            {
                @Override
                public void configure(Binder binder)
                {
                    configBinder(binder).bindConfig(QueryManagerConfig.class);
                    discoveryBinder(binder).bindSelector("presto");
                    discoveryBinder(binder).bindHttpAnnouncement("presto");

                    // Jersey with jetty 9 requires at least one resource
                    // todo add a dummy resource to airlift jaxrs in this case
                    jaxrsBinder(binder).bind(FooResource.class);
                }
            });

    Injector injector = app
            .strictConfig()
            .doNotInitializeLogging()
            .initialize();

    ServiceSelector selector = injector.getInstance(Key.get(ServiceSelector.class, serviceType("presto")));
    assertEquals(selector.selectAllServices().size(), 1);

    HeartbeatFailureDetector detector = injector.getInstance(HeartbeatFailureDetector.class);
    detector.updateMonitoredServices();

    assertEquals(detector.getTotalCount(), 0);
    assertEquals(detector.getActiveCount(), 0);
    assertEquals(detector.getFailedCount(), 0);
    assertTrue(detector.getFailed().isEmpty());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:45,代码来源:TestHeartbeatFailureDetector.java

示例14: create

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config)
{
    requireNonNull(config, "config is null");

    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(
                new NodeModule(),
                new MBeanModule(),
                new JsonModule(),
                new HiveClientModule(connectorId, metastore, typeManager, pageIndexerFactory),
                installModuleIf(
                        SecurityConfig.class,
                        security -> ALLOW_ALL_ACCESS_CONTROL.equalsIgnoreCase(security.getSecuritySystem()),
                        new NoSecurityModule()),
                installModuleIf(
                        SecurityConfig.class,
                        security -> "read-only".equalsIgnoreCase(security.getSecuritySystem()),
                        new ReadOnlySecurityModule()),
                installModuleIf(
                        SecurityConfig.class,
                        security -> "sql-standard".equalsIgnoreCase(security.getSecuritySystem()),
                        new SqlStandardSecurityModule()),
                binder -> {
                    MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
                    binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(platformMBeanServer));
                }
        );

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .setOptionalConfigurationProperties(optionalConfig)
                .initialize();

        LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
        ConnectorMetadata metadata = injector.getInstance(ConnectorMetadata.class);
        ConnectorSplitManager splitManager = injector.getInstance(ConnectorSplitManager.class);
        ConnectorPageSourceProvider connectorPageSource = injector.getInstance(ConnectorPageSourceProvider.class);
        ConnectorPageSinkProvider pageSinkProvider = injector.getInstance(ConnectorPageSinkProvider.class);
        HiveSessionProperties hiveSessionProperties = injector.getInstance(HiveSessionProperties.class);
        HiveTableProperties hiveTableProperties = injector.getInstance(HiveTableProperties.class);
        ConnectorAccessControl accessControl = injector.getInstance(ConnectorAccessControl.class);

        return new HiveConnector(
                lifeCycleManager,
                new ClassLoaderSafeConnectorMetadata(metadata, classLoader),
                new ClassLoaderSafeConnectorSplitManager(splitManager, classLoader),
                new ClassLoaderSafeConnectorPageSourceProvider(connectorPageSource, classLoader),
                new ClassLoaderSafeConnectorPageSinkProvider(pageSinkProvider, classLoader),
                ImmutableSet.of(),
                hiveSessionProperties.getSessionProperties(),
                hiveTableProperties.getTableProperties(),
                accessControl);
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:61,代码来源:HiveConnectorFactory.java

示例15: create

import io.airlift.json.JsonModule; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context)
{
    log.info("In connector factory create method.  Connector id: " + connectorId);
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new KinesisConnectorModule(),
                binder -> {
                    binder.bindConstant().annotatedWith(Names.named("connectorId")).to(connectorId);
                    binder.bind(ConnectorId.class).toInstance(new ConnectorId(connectorId));
                    binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                    binder.bind(NodeManager.class).toInstance(context.getNodeManager());
                    // Note: moved creation from KinesisConnectorModule because connector manager accesses it earlier!
                    binder.bind(KinesisHandleResolver.class).toInstance(new KinesisHandleResolver(connectorName));

                    // Moved creation here from KinesisConnectorModule to make it easier to parameterize
                    if (altProviderClass.isPresent()) {
                        binder.bind(KinesisClientProvider.class).to(altProviderClass.get()).in(Scopes.SINGLETON);
                    }
                    else {
                        binder.bind(KinesisClientProvider.class).to(KinesisClientManager.class).in(Scopes.SINGLETON);
                    }

                    if (tableDescriptionSupplier.isPresent()) {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KinesisStreamDescription>>>() {}).toInstance(tableDescriptionSupplier.get());
                    }
                    else {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KinesisStreamDescription>>>() {}).to(KinesisTableDescriptionSupplier.class).in(Scopes.SINGLETON);
                    }
                }
        );

        this.injector = app.strictConfig()
                    .doNotInitializeLogging()
                    .setRequiredConfigurationProperties(config)
                    .setOptionalConfigurationProperties(optionalConfig)
                    .initialize();

        KinesisConnector connector = this.injector.getInstance(KinesisConnector.class);

        // Register objects for shutdown, at the moment only KinesisTableDescriptionSupplier
        if (!tableDescriptionSupplier.isPresent()) {
            // This will shutdown related dependent objects as well:
            KinesisTableDescriptionSupplier supp = getTableDescSupplier(this.injector);
            connector.registerShutdownObject(supp);
        }

        log.info("Done with injector.  Returning the connector itself.");
        return connector;
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:qubole,项目名称:presto-kinesis,代码行数:59,代码来源:KinesisConnectorFactory.java


注:本文中的io.airlift.json.JsonModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。