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()); }
/** 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; } }
@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; } }
private scribe.Client makeNiftyClient() throws TTransportException, InterruptedException { InetSocketAddress address = new InetSocketAddress("localhost", port); TTransport transport = new NiftyClient().connectSync(scribe.Client.class, new FramedClientConnector(address)); TProtocol protocol = new TBinaryProtocol(transport); return new scribe.Client(protocol); }