本文整理汇总了Java中org.apache.thrift.server.TServer.Args类的典型用法代码示例。如果您正苦于以下问题:Java Args类的具体用法?Java Args怎么用?Java Args使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Args类属于org.apache.thrift.server.TServer包,在下文中一共展示了Args类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
public int run(String[] args) throws Exception
{
Configuration conf = getConf();
int port = conf.getInt("wmr.server.bind.port", 50100);
SubmissionDatabase.connect(conf);
JobServiceHandler service = new JobServiceHandler(new Configuration());
JobService.Processor processor = new JobService.Processor(service);
TServerTransport transport = new TServerSocket(port);
TServer server = new TSimpleServer(new Args(transport).processor(processor));
server.serve();
return 0;
}
开发者ID:benguillet,项目名称:wmr-backend,代码行数:17,代码来源:ThriftServer.java
示例2: startServer
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
@Override
public void startServer(final TProcessor processor, final TProtocolFactory protoFactory) throws Exception {
serverThread = new Thread() {
public void run() {
try {
// Transport
TServerSocket socket = new TServerSocket(PORT);
TTransportFactory factory = new TSaslServerTransport.Factory(
WRAPPED_MECHANISM, SERVICE, HOST, WRAPPED_PROPS,
new TestSaslCallbackHandler(PASSWORD));
server = new TSimpleServer(new Args(socket).processor(processor).transportFactory(factory).protocolFactory(protoFactory));
// Run it
LOGGER.debug("Starting the server on port {}", PORT);
server.serve();
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
};
serverThread.start();
Thread.sleep(1000);
}
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:26,代码来源:TestTSaslTransports.java
示例3: testProcessor
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
private static int testProcessor(TProcessor processor, List<ToIntFunction<HostAndPort>> clients)
throws Exception
{
try (TServerSocket serverTransport = new TServerSocket(0)) {
TProtocolFactory protocolFactory = new Factory();
TTransportFactory transportFactory = new TFramedTransport.Factory();
TServer server = new TSimpleServer(new Args(serverTransport)
.protocolFactory(protocolFactory)
.transportFactory(transportFactory)
.processor(processor));
Thread serverThread = new Thread(server::serve);
try {
serverThread.start();
int localPort = serverTransport.getServerSocket().getLocalPort();
HostAndPort address = HostAndPort.fromParts("localhost", localPort);
int sum = 0;
for (ToIntFunction<HostAndPort> client : clients) {
sum += client.applyAsInt(address);
}
return sum;
}
finally {
server.stop();
serverThread.interrupt();
}
}
}
开发者ID:airlift,项目名称:drift,代码行数:31,代码来源:TestApacheThriftMethodInvoker.java
示例4: testProcessor
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
private static int testProcessor(TProcessor processor, List<ToIntFunction<HostAndPort>> clients)
throws Exception
{
try (TServerSocket serverTransport = new TServerSocket(0)) {
TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
TTransportFactory transportFactory = new TFramedTransport.Factory();
TServer server = new TSimpleServer(new Args(serverTransport)
.protocolFactory(protocolFactory)
.transportFactory(transportFactory)
.processor(processor));
Thread serverThread = new Thread(server::serve);
try {
serverThread.start();
int localPort = serverTransport.getServerSocket().getLocalPort();
HostAndPort address = HostAndPort.fromParts("localhost", localPort);
int sum = 0;
for (ToIntFunction<HostAndPort> client : clients) {
sum += client.applyAsInt(address);
}
return sum;
}
finally {
server.stop();
serverThread.interrupt();
}
}
}
开发者ID:airlift,项目名称:drift,代码行数:31,代码来源:TestDriftNettyMethodInvoker.java
示例5: secure
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
private void secure(Asker.Processor processor) {
try {
/*
* Use TSSLTransportParameters to setup the required SSL parameters. In this example
* we are setting the keystore and the keystore password. Other things like algorithms,
* cipher suites, client auth etc can be set.
*/
TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();
// The Keystore contains the private key
params.setKeyStore(keyStore, keyPass, null, null);
/*
* Use any of the TSSLTransportFactory to get a server transport with the appropriate
* SSL configuration. You can use the default settings if properties are set in the command line.
* Ex: -Djavax.net.ssl.keyStore=.keystore and -Djavax.net.ssl.keyStorePassword=thrift
*
* Note: You need not explicitly call open(). The underlying server socket is bound on return
* from the factory class.
*/
TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(port, 0, null, params);
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
// Use this for a multi threaded server
// TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
System.out.println("Starting the secure server...");
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:altiplanogao,项目名称:rpc-comparison,代码行数:32,代码来源:SecureAskerServer.java
示例6: startExtension
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
/**
* Start extension by communicating with osquery core and starting thrift
* server
*
* @param name
* name of extension
* @param version
* version of extension
* @param sdkVersion
* version of the osquery SDK used to build this extension
* @param minSdkVersion
* minimum version of the osquery SDK that you can use
* @throws IOException
* @throws ExtensionException
*/
public void startExtension(String name, String version, String sdkVersion, String minSdkVersion)
throws IOException, ExtensionException {
ExtensionManager.Client client = new ClientManager(EXTENSION_SOCKET).getClient();
InternalExtensionInfo info = new InternalExtensionInfo(name, version, sdkVersion, minSdkVersion);
try {
ExtensionStatus status = client.registerExtension(info, registry);
if (status.getCode() == 0) {
this.uuid = status.uuid;
Processor<PluginManager> processor = new Processor<PluginManager>(this);
String serverSocketPath = EXTENSION_SOCKET + "." + String.valueOf(uuid);
File socketFile = new File(serverSocketPath);
if (socketFile.exists()) {
socketFile.delete();
}
AFUNIXServerSocket socket = AFUNIXServerSocket.bindOn(new AFUNIXSocketAddress(socketFile));
socketFile.setExecutable(true, false);
socketFile.setWritable(true, false);
socketFile.setReadable(true, false);
TServerSocket transport = new TServerSocket(socket);
TTransportFactory transportFactory = new TTransportFactory();
TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
TServer server = new TSimpleServer(new Args(transport).processor(processor)
.transportFactory(transportFactory).protocolFactory(protocolFactory));
// Run it
System.out.println("Starting the server...");
server.serve();
} else {
throw new ExtensionException(1, status.getMessage(), uuid);
}
} catch (TException e) {
throw new ExtensionException(1, "Could not connect to socket", uuid);
}
}
开发者ID:melastmohican,项目名称:osquery-java,代码行数:50,代码来源:PluginManager.java
示例7: simple
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
public static void simple(Calculator.Processor<CalculatorHandler> processor) throws Exception {
TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(9090);
TServer server = new TNonblockingServer(new TNonblockingServer.Args(serverTransport).processor(processor));
// TServerTransport serverTransport = new TServerSocket(9090);
// TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
// Use this for a multithreaded server
// TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
System.out.println("Starting the simple server...");
server.serve();
}
开发者ID:haogrgr,项目名称:haogrgr-projects,代码行数:14,代码来源:ServerMain.java
示例8: secure
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
public static void secure(Calculator.Processor<CalculatorHandler> processor) throws Exception {
/*
* Use TSSLTransportParameters to setup the required SSL parameters. In this
* example we are setting the keystore and the keystore password. Other things
* like algorithms, cipher suites, client auth etc can be set.
*/
TSSLTransportParameters params = new TSSLTransportParameters();
// The Keystore contains the private key
params.setKeyStore("../../lib/java/test/.keystore", "thrift", null, null);
/*
* Use any of the TSSLTransportFactory to get a server transport with the
* appropriate SSL configuration. You can use the default settings if properties
* are set in the command line. Ex: -Djavax.net.ssl.keyStore=.keystore and
* -Djavax.net.ssl.keyStorePassword=thrift
*
* Note: You need not explicitly call open(). The underlying server socket is
* bound on return from the factory class.
*/
TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(9091, 0, null, params);
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
// Use this for a multi threaded server
// TServer server = new TThreadPoolServer(new
// TThreadPoolServer.Args(serverTransport).processor(processor));
System.out.println("Starting the secure server...");
server.serve();
}
开发者ID:haogrgr,项目名称:haogrgr-projects,代码行数:30,代码来源:ServerMain.java
示例9: simplePrimaryServer
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
public static void simplePrimaryServer (LoadBalancerInvoker.Processor processor, int portNum) {
try {
TServerTransport serverTransport = new TServerSocket (portNum);
TServer server = new TSimpleServer (new Args (serverTransport).processor (processor));
System.out.println ("Starting the simple server...");
server.serve ();
} catch (Exception e) {
e.printStackTrace ();
}
}
开发者ID:mauryat,项目名称:thrift-load-balancer,代码行数:12,代码来源:Server.java
示例10: simpleSecondaryServer
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
public static void simpleSecondaryServer (LoadBalancer.Processor processor, int portNum) {
try {
TServerTransport serverTransport = new TServerSocket (portNum);
TServer server = new TSimpleServer (new Args (serverTransport).processor (processor));
System.out.println ("Starting the simple server...");
server.serve ();
} catch (Exception e) {
e.printStackTrace ();
}
}
开发者ID:mauryat,项目名称:thrift-load-balancer,代码行数:12,代码来源:Server.java
示例11: run
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
public void run() {
log.info("Starting up!");
try {
serverTransport = new TServerSocket(bindAddress);
server = new TSimpleServer(new Args(serverTransport).processor(processor));
server.serve(); // blocks until stop() is called.
// timer and timer task should be stopped at this point
writeToStorage();
} catch (TTransportException e) {
log.error("Couldn't start Configurator {}", this, e);
}
}
开发者ID:xjdr,项目名称:xio,代码行数:13,代码来源:Configurator.java
示例12: simple
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
public static void simple(PacketService.Processor processor) {
try {
TServerTransport serverTransport = new TServerSocket(9888);
server = new TSimpleServer(new Args(serverTransport).processor(processor));
// Use this for a multithreaded server
// TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
System.out.println("Starting the outbound server...");
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:Tryan18,项目名称:XCOM,代码行数:15,代码来源:XCOM_server.java
示例13: simple
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
public static void simple(Calculator.Processor processor) {
try {
TServerTransport serverTransport = new TServerSocket(9090);
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
// Use this for a multithreaded server
// TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
System.out.println("Starting the simple server...");
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:15,代码来源:JavaServer.java
示例14: secure
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
public static void secure(Calculator.Processor processor) {
try {
/*
* Use TSSLTransportParameters to setup the required SSL parameters. In this example
* we are setting the keystore and the keystore password. Other things like algorithms,
* cipher suites, client auth etc can be set.
*/
TSSLTransportParameters params = new TSSLTransportParameters();
// The Keystore contains the private key
params.setKeyStore("../../lib/java/test/.keystore", "thrift", null, null);
/*
* Use any of the TSSLTransportFactory to get a server transport with the appropriate
* SSL configuration. You can use the default settings if properties are set in the command line.
* Ex: -Djavax.net.ssl.keyStore=.keystore and -Djavax.net.ssl.keyStorePassword=thrift
*
* Note: You need not explicitly call open(). The underlying server socket is bound on return
* from the factory class.
*/
TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(9091, 0, null, params);
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
// Use this for a multi threaded server
// TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
System.out.println("Starting the secure server...");
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:32,代码来源:JavaServer.java
示例15: AbstractThriftServer
import org.apache.thrift.server.TServer.Args; //导入依赖的package包/类
/**
*
*/
protected AbstractThriftServer(int port, AbstractAccumuloClient aac, TProcessor processor) throws RebarException {
try {
this.aac = aac;
this.serverXport = new TServerSocket(port);
this.args = new Args(this.serverXport);
this.args.processor(processor);
this.server = new TSimpleServer(this.args);
} catch (TTransportException e) {
throw new RebarException(e);
}
}
开发者ID:hltcoe,项目名称:rebar,代码行数:15,代码来源:AbstractThriftServer.java
注:本文中的org.apache.thrift.server.TServer.Args类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论