Package org.apache.giraph.comm.requests

Examples of org.apache.giraph.comm.requests.WritableRequest


    }
    // Add the message to the cache
    int idSerializerPos = 0;
    int workerMessageSize = 0;
    byte[] serializedId  = null;
    WritableRequest writableRequest = null;
    for (int i = 0; i < idCounter.length; i++) {
      if (idCounter[i] == 1) {
        serializedId = idSerializer[i].getByteArray();
        idSerializerPos = idSerializer[i].getPos();
        // Add the message to the cache
        workerMessageSize = addMessage(workerInfoList[i],
          firstPartitionMap[i], serializedId, idSerializerPos, message);

        if (LOG.isTraceEnabled()) {
          LOG.trace("sendMessageToAllRequest: Send bytes (" +
            message.toString() + ") to one target in  worker " +
            workerInfoList[i]);
        }
        ++totalMsgsSentInSuperstep;
        if (workerMessageSize >= maxMessagesSizePerWorker) {
          PairList<Integer, VertexIdMessages<I, M>>
            workerMessages = removeWorkerMessages(workerInfoList[i]);
          writableRequest = new SendWorkerMessagesRequest<>(workerMessages);
          totalMsgBytesSentInSuperstep += writableRequest.getSerializedSize();
          clientProcessor.doRequest(workerInfoList[i], writableRequest);
          // Notify sending
          getServiceWorker().getGraphTaskManager().notifySentMessages();
        }
      } else if (idCounter[i] > 1) {
        serializedId = idSerializer[i].getByteArray();
        idSerializerPos = idSerializer[i].getPos();
        workerMessageSize = addOneToManyMessage(
            workerInfoList[i], serializedId, idSerializerPos, idCounter[i],
            message);

        if (LOG.isTraceEnabled()) {
          LOG.trace("sendMessageToAllRequest: Send bytes (" +
            message.toString() + ") to all targets in worker" +
            workerInfoList[i]);
        }
        totalMsgsSentInSuperstep += idCounter[i];
        if (workerMessageSize >= maxMessagesSizePerWorker) {
          ByteArrayOneMessageToManyIds<I, M> workerMsgVids =
            removeWorkerMsgVids(workerInfoList[i]);
          writableRequest =  new SendWorkerOneMessageToManyRequest<>(
            workerMsgVids, getConf());
          totalMsgBytesSentInSuperstep += writableRequest.getSerializedSize();
          clientProcessor.doRequest(workerInfoList[i], writableRequest);
          // Notify sending
          getServiceWorker().getGraphTaskManager().notifySentMessages();
        }
      }
View Full Code Here


    PairList<WorkerInfo,
        ByteArrayOneMessageToManyIds<I, M>>.Iterator
    msgIdsIterator = remainingMsgVidsCache.getIterator();
    while (msgIdsIterator.hasNext()) {
      msgIdsIterator.next();
      WritableRequest writableRequest =
        new SendWorkerOneMessageToManyRequest<>(
            msgIdsIterator.getCurrentSecond(), getConf());
      totalMsgBytesSentInSuperstep += writableRequest.getSerializedSize();
      clientProcessor.doRequest(
        msgIdsIterator.getCurrentFirst(), writableRequest);
    }
  }
View Full Code Here

  }

  @Override
  public void channelRead(ChannelHandlerContext ctx, Object msg)
    throws Exception {
    WritableRequest decodedMessage = decode(ctx, msg);
    // Generate SASL response to server using Channel-local SASL client.
    SaslNettyClient saslNettyClient = ctx.attr(NettyClient.SASL).get();
    if (saslNettyClient == null) {
      throw new Exception("handleUpstream: saslNettyClient was unexpectedly " +
          "null for channel: " + ctx.channel());
    }
    if (decodedMessage.getClass() == SaslCompleteRequest.class) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("handleUpstream: Server has sent us the SaslComplete " +
            "message. Allowing normal work to proceed.");
      }
      synchronized (saslNettyClient.getAuthenticated()) {
View Full Code Here

        ctx.channel().remoteAddress());
    }
    // 3. Create object of the type determined in step 2.
    Class<? extends WritableRequest> writableRequestClass =
      type.getRequestClass();
    WritableRequest serverResponse =
      ReflectionUtils.newInstance(writableRequestClass, conf);
    // 4. Deserialize the inputStream's contents into the newly-constructed
    // serverResponse object.
    try {
      serverResponse.readFields(inputStream);
    } catch (IOException e) {
      LOG.error("decode: Exception when trying to read server response: " + e);
    }
    ReferenceCountUtil.release(buf);
    // serverResponse can now be used in the next stage in pipeline.
View Full Code Here

    if (LOG.isTraceEnabled()) {
      LOG.trace("sendVertexRequest: Sending to " + workerInfo +
          ", with partition " + partition);
    }

    WritableRequest vertexRequest = new SendVertexRequest<I, V, E>(partition);
    doRequest(workerInfo, vertexRequest);

    // Messages are stored separately
    if (serviceWorker.getSuperstep() != BspService.INPUT_SUPERSTEP) {
      sendPartitionMessages(workerInfo, partition);
View Full Code Here

      } catch (IOException e) {
        throw new IllegalStateException(
            "sendVertexRequest: Got IOException ", e);
      }
      if (vertexIdMessages.getSize() > maxMessagesSizePerWorker) {
        WritableRequest messagesRequest = new
            SendPartitionCurrentMessagesRequest<I, V, E, Writable>(
            partitionId, vertexIdMessages);
        doRequest(workerInfo, messagesRequest);
        vertexIdMessages =
            new ByteArrayVertexIdMessages<I, Writable>(
                configuration.getOutgoingMessageValueFactory());
        vertexIdMessages.setConf(configuration);
        vertexIdMessages.initialize();
      }
    }
    if (!vertexIdMessages.isEmpty()) {
      WritableRequest messagesRequest = new
          SendPartitionCurrentMessagesRequest<I, V, E, Writable>(
          partitionId, vertexIdMessages);
      doRequest(workerInfo, messagesRequest);
    }
  }
View Full Code Here

    // the remote worker 'workerInfo' is full enough to be flushed
    if (workerMessageSize >= maxVerticesSizePerWorker) {
      PairList<Integer, ExtendedDataOutput>
          workerPartitionVertices =
          sendPartitionCache.removeWorkerData(partitionOwner.getWorkerInfo());
      WritableRequest writableRequest =
          new SendWorkerVerticesRequest<I, V, E>(
              configuration, workerPartitionVertices);
      doRequest(partitionOwner.getWorkerInfo(), writableRequest);
      return true;
    }
View Full Code Here

    throws Exception {
    if (LOG.isTraceEnabled()) {
      LOG.trace("messageReceived: Got " + msg.getClass());
    }

    WritableRequest request = (WritableRequest) msg;

    // Simulate a closed connection on the first request (if desired)
    if (closeFirstRequest && !ALREADY_CLOSED_FIRST_REQUEST) {
      LOG.info("messageReceived: Simulating closing channel on first " +
          "request " + request.getRequestId() + " from " +
          request.getClientId());
      setAlreadyClosedFirstRequest();
      ctx.close();
      return;
    }

    // Only execute this request exactly once
    int alreadyDone = 1;
    if (workerRequestReservedMap.reserveRequest(
        request.getClientId(),
        request.getRequestId())) {
      if (LOG.isDebugEnabled()) {
        startProcessingNanoseconds = TIME.getNanoseconds();
      }
      processRequest((R) request);
      if (LOG.isDebugEnabled()) {
        LOG.debug("messageReceived: Processing client " +
            request.getClientId() + ", " +
            "requestId " + request.getRequestId() +
            ", " +  request.getType() + " took " +
            Times.getNanosSince(TIME, startProcessingNanoseconds) + " ns");
      }
      alreadyDone = 0;
    } else {
      LOG.info("messageReceived: Request id " +
          request.getRequestId() + " from client " +
          request.getClientId() +
          " was already processed, " +
          "not processing again.");
    }

    // Send the response with the request id
    ByteBuf buffer = ctx.alloc().buffer(RESPONSE_BYTES);
    buffer.writeInt(myTaskInfo.getTaskId());
    buffer.writeLong(request.getRequestId());
    buffer.writeByte(alreadyDone);

    ctx.write(buffer);
  }
View Full Code Here

    // Send a request if the cache of outgoing edges to the remote worker is
    // full
    if (workerEdgesSize >= maxEdgesSizePerWorker) {
      PairList<Integer, VertexIdEdges<I, E>> workerEdges =
          sendEdgeCache.removeWorkerEdges(workerInfo);
      WritableRequest writableRequest =
          new SendWorkerEdgesRequest<I, E>(workerEdges);
      doRequest(workerInfo, writableRequest);
      return true;
    }
View Full Code Here

      int partitionMutationCount) {
    // Send a request if enough mutations are there for a partition
    if (partitionMutationCount >= maxMutationsPerPartition) {
      Map<I, VertexMutations<I, V, E>> partitionMutations =
          sendMutationsCache.removePartitionMutations(partitionId);
      WritableRequest writableRequest =
          new SendPartitionMutationsRequest<I, V, E>(
              partitionId, partitionMutations);
      doRequest(partitionOwner.getWorkerInfo(), writableRequest);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.giraph.comm.requests.WritableRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.