本文整理匯總了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));
}