當前位置: 首頁>>代碼示例>>Java>>正文


Java GearmanNIOJobServerConnection類代碼示例

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

}
 
開發者ID:openstack-infra,項目名稱:gearman-plugin,代碼行數:40,代碼來源:StartJobClient.java

示例2: initWorker

import org.gearman.common.GearmanNIOJobServerConnection; //導入依賴的package包/類
protected void initWorker() {
    synchronized(this) {
        if (running) {
            worker = new MyGearmanWorkerImpl(getAvailability());
            conn = new GearmanNIOJobServerConnection(host, port);
        }
    }
}
 
開發者ID:openstack-infra,項目名稱:gearman-plugin,代碼行數:9,代碼來源:AbstractWorkerThread.java

示例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);
 }
 
開發者ID:openstack-infra,項目名稱:gearman-plugin,代碼行數:10,代碼來源:AbstractWorkerThreadTest.java

示例4: getGearmanConnection

import org.gearman.common.GearmanNIOJobServerConnection; //導入依賴的package包/類
protected GearmanJobServerConnection getGearmanConnection(String hostname, int port) {
    return new GearmanNIOJobServerConnection(hostname, port);
}
 
開發者ID:ConSol,項目名稱:sakuli,代碼行數:4,代碼來源:GearmanResultServiceImpl.java

示例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));
}
 
開發者ID:52Jolynn,項目名稱:Paper2Swf,代碼行數:11,代碼來源:PdfConvertClient.java

示例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);
}
 
開發者ID:52Jolynn,項目名稱:Paper2Swf,代碼行數:11,代碼來源:WorkerRunner.java

示例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));
}
 
開發者ID:52Jolynn,項目名稱:Paper2Swf,代碼行數:11,代碼來源:SwfConvertClient.java


注:本文中的org.gearman.common.GearmanNIOJobServerConnection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。