本文整理汇总了Java中org.gearman.common.GearmanNIOJobServerConnection类的典型用法代码示例。如果您正苦于以下问题:Java GearmanNIOJobServerConnection类的具体用法?Java GearmanNIOJobServerConnection怎么用?Java GearmanNIOJobServerConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GearmanNIOJobServerConnection类属于org.gearman.common包,在下文中一共展示了GearmanNIOJobServerConnection类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.gearman.common.GearmanNIOJobServerConnection; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
// setup connection settings
String host = "127.0.0.1";
int port = 4730;
// setup job parameters
String function = "build:pep8:precise";
String uniqueId = UUID.randomUUID().toString();
String params = "{param1:red, param2:white, param3:blue}";
// connect client to server
GearmanClient client = new GearmanClientImpl();
GearmanNIOJobServerConnection conn = new GearmanNIOJobServerConnection(host, port);
client.addJobServer(conn);
// send job request
byte[] data = ByteUtils.toUTF8Bytes(params);
GearmanJob job = GearmanJobImpl.createJob(function, data, uniqueId);
client.submit(job);
// get results
String value = "";
GearmanJobResult res = null;
try {
res = job.get();
value = ByteUtils.fromUTF8Bytes(res.getResults());
System.out.println("Job Result: "+value);
} catch (Exception e) {
e.printStackTrace();
}
// close client
client.shutdown();
}
示例2: initWorker
import org.gearman.common.GearmanNIOJobServerConnection; //导入依赖的package包/类
protected void initWorker() {
synchronized(this) {
if (running) {
worker = new MyGearmanWorkerImpl(getAvailability());
conn = new GearmanNIOJobServerConnection(host, port);
}
}
}
示例3: setUp
import org.gearman.common.GearmanNIOJobServerConnection; //导入依赖的package包/类
/**
*/
@Before
public void setUp() {
GearmanWorker gearmanWorker = mock(GearmanWorker.class);
GearmanNIOJobServerConnection conn = new GearmanNIOJobServerConnection("localhost", 4730);
doNothing().when(gearmanWorker).work();
when(gearmanWorker.addServer(conn)).thenReturn(true);
}
示例4: getGearmanConnection
import org.gearman.common.GearmanNIOJobServerConnection; //导入依赖的package包/类
protected GearmanJobServerConnection getGearmanConnection(String hostname, int port) {
return new GearmanNIOJobServerConnection(hostname, port);
}
示例5: PdfConvertClient
import org.gearman.common.GearmanNIOJobServerConnection; //导入依赖的package包/类
/**
*
* @param host
* job server服务地址
* @param port
* job server服务端口
*/
public PdfConvertClient(String host, int port) {
this(new GearmanNIOJobServerConnection(host, port));
}
示例6: WorkerRunner
import org.gearman.common.GearmanNIOJobServerConnection; //导入依赖的package包/类
/**
*
* @param host
* job server服务地址
* @param port
* job server服务端口
*/
public WorkerRunner(String host, int port) {
conn = new GearmanNIOJobServerConnection(host, port);
}
示例7: SwfConvertClient
import org.gearman.common.GearmanNIOJobServerConnection; //导入依赖的package包/类
/**
*
* @param host
* job server服务地址
* @param port
* job server服务端口
*/
public SwfConvertClient(String host, int port) {
this(new GearmanNIOJobServerConnection(host, port));
}