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


Java ThriftClientManager类代码示例

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


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

示例1: main

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
/** 
 * @param args 
 */  
public static void main(String[] args) throws Exception {  
	/**
    TTransport transport = new TSocket("localhost", 8080);  
    transport.open();  
    TProtocol protocol = new TBinaryProtocol(transport);  
    ThriftTestService.Client client = new ThriftTestService.Client(protocol);  
    System.out.println(client.test("name"));  
    transport.close();  **/
	InMemoryScribe client;
	ThriftCodecManager thriftCodecManager = new ThriftCodecManager();
	HttpClientConnector connector = new HttpClientConnector(URI.create("http://localhost:" + 8080 +"/scribe"));

    ThriftClientManager clientManager = new ThriftClientManager(thriftCodecManager);
    client = clientManager.createClient(connector, InMemoryScribe.class).get();
    List<LogEntry> msgs = new ArrayList<LogEntry>();
    String name = client.log(msgs);
    System.out.println("name: "+ name);
}
 
开发者ID:tiaoling,项目名称:high,代码行数:22,代码来源:Client.java

示例2: testNonExistent

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
@Test
public void testNonExistent() throws Exception
{
    final int port = NetUtils.findUnusedPort();

    final HiveMetastoreClientConfig metastoreConfig = new HiveMetastoreClientConfig()
        .setPort(port)
        .setMaxRetries(5)
        .setRetrySleep(new Duration(1, TimeUnit.SECONDS))
        .setRetryTimeout(new Duration(30, TimeUnit.SECONDS));

    try (final ThriftClientManager clientManager = new ThriftClientManager()) {
        final ThriftClientConfig clientConfig = new ThriftClientConfig();
        final HiveMetastoreFactory factory = new SimpleHiveMetastoreFactory(clientManager, clientConfig, metastoreConfig);

        try (final HiveMetastore metastore = factory.getDefaultClient()) {
            assertFalse(metastore.isConnected());
            metastore.getTable("hello", "world");
            fail();
        }
        catch (TTransportException te) {
            assertEquals(TTransportException.UNKNOWN, te.getType());
        }
    }
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:26,代码来源:TestRetryingHiveMetastore.java

示例3: testSimple

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
@Test
public void testSimple() throws Exception
{
    final int port = NetUtils.findUnusedPort();

    startService(port);

    final HiveMetastoreClientConfig metastoreConfig = new HiveMetastoreClientConfig().setPort(port);
    try (final ThriftClientManager clientManager = new ThriftClientManager()) {
        final ThriftClientConfig clientConfig = new ThriftClientConfig();
        final HiveMetastoreFactory factory = new SimpleHiveMetastoreFactory(clientManager, clientConfig, metastoreConfig);

        try (final HiveMetastore metastore = factory.getDefaultClient()) {
            final Table table = metastore.getTable("hello", "world");
            assertNotNull(table);
            assertEquals("hello", table.getDbName());
            assertEquals("world", table.getTableName());
        }
    }
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:21,代码来源:TestHiveMetastoreClient.java

示例4: testLateConnectIsOk

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
@Test
public void testLateConnectIsOk() throws Exception
{
    final int port = NetUtils.findUnusedPort();

    final HiveMetastoreClientConfig metastoreConfig = new HiveMetastoreClientConfig().setPort(port);
    final ThriftClientConfig clientConfig = new ThriftClientConfig();
    try (final ThriftClientManager clientManager = new ThriftClientManager()) {
        final HiveMetastoreFactory factory = new SimpleHiveMetastoreFactory(clientManager, clientConfig, metastoreConfig);

        try (final HiveMetastore metastore = factory.getDefaultClient()) {
            assertFalse(metastore.isConnected());
        }

        startService(port);

        try (final HiveMetastore metastore = factory.getDefaultClient()) {
            final Table table = metastore.getTable("hello", "world");
            assertNotNull(table);
            assertEquals("hello", table.getDbName());
            assertEquals("world", table.getTableName());
        }
    }
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:25,代码来源:TestHiveMetastoreClient.java

示例5: main

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
public static void main(String[] args) throws ExecutionException, InterruptedException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
       ThriftClientManager clientManager = new ThriftClientManager();
       FramedClientConnector connector = new FramedClientConnector(new InetSocketAddress("localhost",8899));
       ThirdPartyCollectionService scribe = clientManager.createClient(connector, ThirdPartyCollectionService.class).get();
       //scribe.getAll();
       ThirdPartyCollection collection =
               new ThirdPartyCollection(1001, "2014-08-29");
       ThirdPartyCollection co2 = scribe.save(collection);
       System.out.println("c:"+ co2.getId());
       System.out.println("c:"+ co2.getDate());
}
 
开发者ID:tiaoling,项目名称:high,代码行数:12,代码来源:TheAppClient.java

示例6: setUp

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    HttpClientConnector connector = new HttpClientConnector(URI.create("http://localhost:" + port + "/thrift/"));

    ThriftClientManager clientManager = new ThriftClientManager(thriftCodecManager);
    client = clientManager.createClient(connector, TCalculatorService.class).get();
}
 
开发者ID:tiaoling,项目名称:high,代码行数:8,代码来源:CalculatorApplicationTest.java

示例7: setUp

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
/** Sets up clients before each benchmark */
private void setUp() throws Exception {
  try {
    fileSystem = (DistributedFileSystem) FileSystem.get(
        StorageServiceConfigKeys.translateToOldSchema(conf, nameserviceId), conf);
    InetSocketAddress nameNodeAddr = fileSystem.getClient().getNameNodeAddr();
    metaInfo = new RequestMetaInfo(clusterId, nameserviceId, RequestMetaInfo.NO_NAMESPACE_ID,
        RequestMetaInfo.NO_APPLICATION_ID, (UnixUserGroupInformation) UserGroupInformation.getUGI(
        this.conf));

    directClientProtocol = RPC.getProxy(ClientProtocol.class, ClientProtocol.versionID,
        nameNodeAddr, conf);

    directClientProxyProtocol = RPC.getProxy(ClientProxyProtocol.class,
        ClientProxyProtocol.versionID, nameNodeAddr, conf);

    clientManager = new ThriftClientManager();
    FramedClientConnector connector = new FramedClientConnector(HostAndPort.fromParts(
        proxyHostname, proxyPortThrift));
    proxyTClientProxyProtocol = clientManager.createClient(connector, TClientProxyProtocol.class)
        .get();

    proxyClientProxyProtocol = RPC.getProxy(ClientProxyProtocol.class,
        ClientProxyProtocol.versionID, new InetSocketAddress(proxyHostname, proxyPortRPC), conf);

    fileSystem.mkdirs(new Path(ROOT));
  } catch (Exception e) {
    tearDown();
    throw e;
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:32,代码来源:NNLatencyBenchmark.java

示例8: setUp

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  try {
    Configuration conf = new Configuration();
    // Bind ports automatically
    conf.setInt(StorageServiceConfigKeys.PROXY_THRIFT_PORT_KEY, 0);
    conf.setInt(StorageServiceConfigKeys.PROXY_RPC_PORT_KEY, 0);

    cluster = new MiniAvatarCluster(conf, 2, true, null, null, 1, true);
    fs = cluster.getFileSystem(0);

    metaInfo = new RequestMetaInfo(conf.getInt(FSConstants.DFS_CLUSTER_ID,
        RequestMetaInfo.NO_CLUSTER_ID), cluster.getNameNode(0).getNameserviceId(),
        RequestMetaInfo.NO_NAMESPACE_ID, RequestMetaInfo.NO_APPLICATION_ID,
        (UnixUserGroupInformation) UserGroupInformation.getUGI(conf));

    proxy = new ClientProxyService(new ClientProxyCommons(conf, conf.get(
        FSConstants.DFS_CLUSTER_NAME)));
    conf.setInt(StorageServiceConfigKeys.PROXY_THRIFT_PORT_KEY, proxy.getThriftPort());
    conf.setInt(StorageServiceConfigKeys.PROXY_RPC_PORT_KEY, proxy.getRPCPort());

    clientManager = new ThriftClientManager();
    FramedClientConnector connector = new FramedClientConnector(
        StorageServiceConfigKeys.getProxyThriftAddress(conf));
    clientThrift = clientManager.createClient(connector, TClientProxyProtocol.class).get();

    clientRPC = RPC.getProxy(ClientProxyProtocol.class, ClientProxyProtocol.versionID,
        StorageServiceConfigKeys.getProxyRPCAddress(conf), conf);
  } catch (IOException e) {
    tearDown();
    throw e;
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:34,代码来源:TestClientProxyService.java

示例9: HiveMetaStoreClient

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
public HiveMetaStoreClient(HiveConf conf)
    throws MetaException
{
    this.thriftClientManager = closer.register(new ThriftClientManager());

    if (conf == null) {
        conf = new HiveConf(HiveMetaStoreClient.class);
    }
    this.conf = conf;

    String msUri = conf.getVar(HiveConf.ConfVars.METASTOREURIS);
    if (msUri == null || msUri.trim().length() == 0) {
        throw new MetaException("Local metastore is not supported!");
    }

    if (conf.getBoolVar(ConfVars.METASTORE_USE_THRIFT_SASL)) {
        throw new MetaException("SASL is not supported");
    }

    // get the number retries
    this.retries = HiveConf.getIntVar(conf, HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES);
    this.retryDelaySeconds = conf.getIntVar(ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY);

    // user wants file store based configuration
    List<String> metastoreUris = ImmutableList.copyOf(Splitter.on(',').omitEmptyStrings().trimResults().split(msUri));

    metastoreHosts = new HostAndPort [metastoreUris.size()];

    for (int i = 0; i < metastoreUris.size(); i++) {
        URI uri = URI.create(metastoreUris.get(i));
        if (!uri.getScheme().equals("thrift")) {
            throw new MetaException("Only thrift:// URIs are supported!");
        }
        metastoreHosts[i] = HostAndPort.fromParts(uri.getHost(), uri.getPort());
    }

    // finally open the store
    open();
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:40,代码来源:HiveMetaStoreClient.java

示例10: SimpleHiveMetastoreFactory

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
public SimpleHiveMetastoreFactory(final ThriftClientManager thriftClientManager,
                                  final ThriftClientConfig thriftClientConfig,
                                  final HiveMetastoreClientConfig hiveMetastoreClientConfig)
{
    super(hiveMetastoreClientConfig,
          new ThriftClient<>(checkNotNull(thriftClientManager, "thiftClientManager is null"),
                             HiveMetastore.class,
                             checkNotNull(thriftClientConfig, "thriftClientConfig is null"),
                             "hive-metastore"));
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:11,代码来源:SimpleHiveMetastoreFactory.java

示例11: testExisting

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
@Test
public void testExisting() throws Exception
{
    final int port = NetUtils.findUnusedPort();

    startService(port);

    final HiveMetastoreClientConfig metastoreConfig = new HiveMetastoreClientConfig()
        .setPort(port)
        .setMaxRetries(5)
        .setRetrySleep(new Duration(1, TimeUnit.SECONDS))
        .setRetryTimeout(new Duration(30, TimeUnit.SECONDS));

    try (final ThriftClientManager clientManager = new ThriftClientManager()) {
        final ThriftClientConfig clientConfig = new ThriftClientConfig();
        final HiveMetastoreFactory factory = new SimpleHiveMetastoreFactory(clientManager, clientConfig, metastoreConfig);

        try (final HiveMetastore metastore = factory.getDefaultClient()) {
            assertFalse(metastore.isConnected());

            final Table table = metastore.getTable("hello", "world");
            assertNotNull(table);
            assertEquals("hello", table.getDbName());
            assertEquals("world", table.getTableName());

            assertTrue(metastore.isConnected());
        }
    }
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:30,代码来源:TestRetryingHiveMetastore.java

示例12: testLate

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
@Test
public void testLate() throws Exception
{
    final int port = NetUtils.findUnusedPort();


    runner.schedule(new Runnable() {
        @Override
        public void run() {
            try {
                startService(port);
            }
            catch (Exception e) {
                fail(e.getMessage());
            }
        }
    }, 10, TimeUnit.SECONDS);

    final HiveMetastoreClientConfig metastoreConfig = new HiveMetastoreClientConfig()
        .setPort(port)
        .setMaxRetries(5)
        .setRetrySleep(new Duration(5, TimeUnit.SECONDS))
        .setRetryTimeout(new Duration(30, TimeUnit.SECONDS));

    try (final ThriftClientManager clientManager = new ThriftClientManager()) {
        final ThriftClientConfig clientConfig = new ThriftClientConfig();
        final HiveMetastoreFactory factory = new SimpleHiveMetastoreFactory(clientManager, clientConfig, metastoreConfig);

        try (final HiveMetastore metastore = factory.getDefaultClient()) {
            assertFalse(metastore.isConnected());

            final Table table = metastore.getTable("hello", "world");
            assertNotNull(table);
            assertEquals("hello", table.getDbName());
            assertEquals("world", table.getTableName());

            assertTrue(metastore.isConnected());
        }
    }
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:41,代码来源:TestRetryingHiveMetastore.java

示例13: testLetsShuffleOne

import com.facebook.swift.service.ThriftClientManager; //导入依赖的package包/类
@Test
public void testLetsShuffleOne() throws Exception
{
    final int port = NetUtils.findUnusedPort();

    final ImmutableSet.Builder<HostAndPort> builder = ImmutableSet.builder();
    builder.add(HostAndPort.fromParts("localhost", port));

    for (int i = 0; i < 3; i++) {
        builder.add(HostAndPort.fromParts("localhost", NetUtils.findUnusedPort()));
    }

    runner.schedule(new Runnable() {
        @Override
        public void run() {
            try {
                startService(port);
            }
            catch (Exception e) {
                fail(e.getMessage());
            }
        }
    }, 10, TimeUnit.SECONDS);

    final HiveMetastoreClientConfig metastoreConfig = new HiveMetastoreClientConfig()
        .setMaxRetries(10)
        .setRetrySleep(new Duration(3, TimeUnit.SECONDS))
        .setRetryTimeout(new Duration(45, TimeUnit.SECONDS));

    try (final ThriftClientManager clientManager = new ThriftClientManager()) {
        final ThriftClientConfig clientConfig = new ThriftClientConfig();
        final HiveMetastoreFactory factory = new SimpleHiveMetastoreFactory(clientManager, clientConfig, metastoreConfig);

        try (final HiveMetastore metastore = factory.getClientForHost(builder.build())) {
            assertFalse(metastore.isConnected());

            final Table table = metastore.getTable("hello", "world");
            assertNotNull(table);
            assertEquals("hello", table.getDbName());
            assertEquals("world", table.getTableName());

            assertTrue(metastore.isConnected());
        }
    }
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:46,代码来源:TestRetryingHiveMetastore.java


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