예제 #1
0
  private final void text_maxqueue(final String[] args, final ServerClient client) {
    final byte[] funcName = args[1].getBytes(GearmanConstants.UTF_8);
    if (funcName == null) {
      client.sendPacket(ServerStaticPackets.TEXT_INCOMPLETE_ARGS, null /*TODO*/);
      return;
    }
    final ByteArray funcNameBA = new ByteArray(funcName);

    final String sizeStr = args[2];
    if (sizeStr == null) {
      client.sendPacket(ServerStaticPackets.TEXT_INCOMPLETE_ARGS, null /*TODO*/);
      return;
    }

    final int size;
    try {
      size = Integer.parseInt(sizeStr);
    } catch (NumberFormatException e) {
      client.sendPacket(ServerStaticPackets.TEXT_OK, null /*TODO*/);
      return;
    }

    /*
     * FWIX CHANGE
     */
    // final ServerFunction func = this.funcSet.getFunctionIfDefined(funcNameBA);

    funcSet.setMaxQueueByName(funcNameBA, size);
  }
예제 #2
0
  private final void submit_job(
      final GearmanPacket packet,
      final ServerClient client,
      ServerJob.JobPriority priority,
      boolean isBackground) {

    /*
     * A client issues this when a job needs to be run. The server will
     * then assign a job handle and respond with a JOB_CREATED packet.
     *
     * If on of the BG versions is used, the client is not updated with
     * status or notified when the job has completed (it is detached).
     *
     * The Gearman job server queue is implemented with three levels:
     * normal, high, and low. Jobs submitted with one of the HIGH versions
     * always take precedence, and jobs submitted with the normal versions
     * take precedence over the LOW versions.
     *
     * Arguments:
     * - NULL byte terminated function name.
     * - NULL byte terminated unique ID.
     * - Opaque data that is given to the function as an argument.
     */

    // Argument: function name
    final byte[] funcName = packet.getArgumentData(0);
    assert funcName != null;
    final ByteArray funcNameBA = new ByteArray(funcName);

    // Argument: unique ID
    final byte[] uniqueID = packet.getArgumentData(1);
    assert uniqueID != null;
    final ByteArray uniqueIDBA = new ByteArray(uniqueID);

    // Argument: data
    final byte[] data = packet.getArgumentData(2);
    assert data != null;

    /*
     * FWIX CHANGE
     */
    // final ServerFunction func = this.funcSetHigh.getFunction(funcNameBA);

    funcSet.createJob(funcNameBA, uniqueIDBA, data, priority, client, isBackground);
  }
예제 #3
0
  /**
   * Called when a CAN_DO packet comes in.<br>
   * <br>
   * <i> CAN_DO:<br>
   * This is sent to notify the server that the client is able to perform the given function. The
   * client is then put on a list to be waken up whenever the job server receives a job for that
   * function.<br>
   * <br>
   * Arguments:<br>
   * - Function name.<br>
   * </i>
   *
   * @param packet The CAN_DO packet
   * @param client The client who acquired the packet.
   */
  private final void can_do(final GearmanPacket packet, final ServerClient client) {

    // Note: Currently the CAN_DO_TIMEOUT maps to this method, the timeout
    // feature will be fully implemented in the future.

    // Function Name
    final byte[] funcName = packet.getArgumentData(0);
    assert funcName != null;

    if (funcName.length == 0) {
      // TODO send error
    }

    ByteArray funcNameBA = new ByteArray(funcName);
    // funcNameBA = GMServerFunctionMap.GM_TASK_BA;

    funcSet.registerClient(funcNameBA, client);
  }
예제 #4
0
 public void removeJobs(String function) {
   funcSet.removeJobs(function);
 }