public boolean encode(Routable obj, DocumentSerializer out) { if (!(obj instanceof DocumentReply)) { throw new AssertionError( "Document reply factory (" + getClass().getName() + ") registered for incompatible " + "routable type " + obj.getType() + "(" + obj.getClass().getName() + ")."); } DocumentReply reply = (DocumentReply)obj; out.putByte(null, (byte)(reply.getPriority().getValue())); return doEncode(reply, out); }
sb.append(" Visitor ordering: ").append(visitorOrdering).append('\n'); sb.append(" Max buckets: ").append(maxBucketsPerVisitor).append('\n'); sb.append(" Priority: ").append(getPriority().toString()).append('\n'); if (dynamicallyIncreaseMaxBucketsPerVisitor) { sb.append(" Dynamically increasing max buckets per visitor\n");
/** * Used by config to generate priorities for a name, and add them to the load type set. */ public void addType(String name, String priority) { try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(name.getBytes()); byte messageDigest[] = algorithm.digest(); int id = 0; for (int i = 0; i < 4; i++) { int temp = ((int)messageDigest[i] & 0xff); id <<= 8; id |= temp; } map.put(new LoadType(id, name, DocumentProtocol.Priority.valueOf(priority != null ? priority : "NORMAL_3"))); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
private void setMessageParameters(DocumentOperationMessageV3 msg, FeederSettings settings) { msg.getMessage().setContext(new ReplyContext(msg.getOperationId(), feedReplies, DocumentOperationType.fromMessage(msg.getMessage()))); if (settings.traceLevel != null) { msg.getMessage().getTrace().setLevel(settings.traceLevel); } if (settings.priority != null) { try { DocumentProtocol.Priority priority = DocumentProtocol.Priority.valueOf(settings.priority); if (msg.getMessage() instanceof DocumentMessage) { ((DocumentMessage) msg.getMessage()).setPriority(priority); } } catch (IllegalArgumentException i) { log.severe(i.getMessage()); } } }
public DocumentMessage fromDocumentOperation(Processing processing, DocumentOperation documentOperation) { DocumentMessage msg = newMessage(documentOperation); msg.setLoadType(loadType); msg.setPriority(priority); msg.setRoute(requestMsg.getRoute()); msg.setTimeReceivedNow(); msg.setTimeRemaining(requestMsg.getTimeRemainingNow()); msg.getTrace().setLevel(requestMsg.getTrace().getLevel()); if (log.isLoggable(LogLevel.DEBUG)) { log.log(LogLevel.DEBUG, "Created '" + msg.getClass().getName() + "', route = '" + msg.getRoute() + "', priority = '" + msg.getPriority().name() + "', load type = '" + msg.getLoadType() + "', trace level = '" + msg.getTrace().getLevel() + "', time remaining = '" + msg.getTimeRemaining() + "'."); } return msg; }
/** * Get a priority enum instance by its value. * * @param val The value of the priority to return. * @return The priority enum instance. * @throws IllegalArgumentException If priority value is unknown. */ public static Priority getPriority(int val) { for (Priority pri : Priority.values()) { if (val == pri.val) { return pri; } } throw new IllegalArgumentException("Unknown priority: " + val); }
@Override public int getPriority() { return requestMsg.getPriority().getValue(); }
/** * Get priority enum instance by its name. * * @param name Name of priority. * @return Priority enum instance, given that <code>name</code> is valid. * @throws IllegalArgumentException If priority name is unknown. */ public static Priority getPriorityByName(String name) { return Priority.valueOf(name); }
public void configure(LoadTypeConfig config) { DualMap newMap = new DualMap(); // Default should always be available. newMap.put(LoadType.DEFAULT); for (LoadTypeConfig.Type t : config.type()) { newMap.put(new LoadType(t.id(), t.name(), DocumentProtocol.Priority.valueOf(t.priority()))); } map = newMap; } }
private LoadTypeConfig.Type.Builder getLoadTypeConfig(LoadType loadType) { LoadTypeConfig.Type.Builder builder = new LoadTypeConfig.Type.Builder(); builder.name(loadType.getName()); builder.id(loadType.getId()); builder.priority(loadType.getPriority().toString()); return builder; }
public boolean encode(Routable obj, DocumentSerializer out) { if (!(obj instanceof DocumentMessage)) { throw new AssertionError( "Document message factory (" + getClass().getName() + ") registered for incompatible " + "routable type " + obj.getType() + "(" + obj.getClass().getName() + ")."); } DocumentMessage msg = (DocumentMessage)obj; out.putByte(null, (byte)(msg.getPriority().getValue())); out.putInt(null, msg.getLoadType().getId()); return doEncode(msg, out); }