📄 multiringendpoint.java
字号:
* object with a given id can be stored. The call returns nodes up to and * including a node with maxRank. This call also allows the application to * provide a remove "center" node, as well as other nodes in the vicinity. * * @param id The object's id. * @param maxRank The number of desired replicas. * @param set The set of other nodes around the root handle * @param root DESCRIBE THE PARAMETER * @return DESCRIBE THE RETURN VALUE */ public NodeHandleSet replicaSet(Id id, int maxRank, NodeHandle root, NodeHandleSet set) { if (((RingId) id).getRingId().equals(node.getRingId())) { return new MultiringNodeHandleSet(node.getRingId(), endpoint.replicaSet(((RingId) id).getId(), maxRank, ((MultiringNodeHandle) root).getHandle(), ((MultiringNodeHandleSet) set).getSet())); } else { return new MultiringNodeHandleSet(((RingId) id).getRingId(), node.getNode().getIdFactory().buildNodeHandleSet()); } } /** * This operation provides information about ranges of keys for which the node * is currently a rank-root. The operations returns null if the range could * not be determined, the range otherwise. It is an error to query the range * of a node not present in the neighbor set as returned bythe update upcall * or the neighborSet call. Certain implementations may return an error if * rank is greater than zero. Some protocols may have multiple, disjoint * ranges of keys for which a given node is responsible. The parameter lkey * allows the caller to specify which region should be returned. If the node * referenced by is responsible for key lkey, then the resulting range * includes lkey. Otherwise, the result is the nearest range clockwise from * lkey for which is responsible. * * @param handle The handle whose range to check. * @param rank The root rank. * @param lkey An "index" in case of multiple ranges. * @return DESCRIBE THE RETURN VALUE */ public IdRange range(NodeHandle handle, int rank, Id lkey) { if (lkey != null) { lkey = ((RingId) lkey).getId(); } IdRange result = endpoint.range(((MultiringNodeHandle) handle).getHandle(), rank, lkey); if (result != null) { return new MultiringIdRange(node.getRingId(), result); } else { return null; } } /** * This operation provides information about ranges of keys for which the node * is currently a rank-root. The operations returns null if the range could * not be determined, the range otherwise. It is an error to query the range * of a node not present in the neighbor set as returned bythe update upcall * or the neighborSet call. Certain implementations may return an error if * rank is greater than zero. Some protocols may have multiple, disjoint * ranges of keys for which a given node is responsible. The parameter lkey * allows the caller to specify which region should be returned. If the node * referenced by is responsible for key lkey, then the resulting range * includes lkey. Otherwise, the result is the nearest range clockwise from * lkey for which is responsible. * * @param handle The handle whose range to check. * @param rank The root rank. * @param lkey An "index" in case of multiple ranges. * @param cumulative Whether to return the cumulative or single range * @return DESCRIBE THE RETURN VALUE */ public IdRange range(NodeHandle handle, int rank, Id lkey, boolean cumulative) { if (lkey != null) { lkey = ((RingId) lkey).getId(); } IdRange result = endpoint.range(((MultiringNodeHandle) handle).getHandle(), rank, lkey, cumulative); if (result != null) { return new MultiringIdRange(node.getRingId(), result); } else { return null; } } /** * Schedules a message to be delivered to this application after the provided * number of milliseconds. * * @param message The message to be delivered * @param delay The number of milliseconds to wait before delivering the * message * @return DESCRIBE THE RETURN VALUE */ public CancellableTask scheduleMessage(Message message, long delay) { return endpoint.scheduleMessage(message, delay); } /** * Schedules a message to be delivered to this application every period number * of milliseconds, after delay number of miliseconds have passed. * * @param message The message to be delivered * @param delay The number of milliseconds to wait before delivering the fist * message * @param period DESCRIBE THE PARAMETER * @return DESCRIBE THE RETURN VALUE */ public CancellableTask scheduleMessage(Message message, long delay, long period) { return endpoint.scheduleMessage(message, delay, period); } /** * DESCRIBE THE METHOD * * @param message DESCRIBE THE PARAMETER * @param delay DESCRIBE THE PARAMETER * @param period DESCRIBE THE PARAMETER * @return DESCRIBE THE RETURN VALUE */ public CancellableTask scheduleMessageAtFixedRate(Message message, long delay, long period) { return endpoint.scheduleMessageAtFixedRate(message, delay, period); } /** * Schedules a job for processing on the dedicated processing thread. CPU * intensive jobs, such as encryption, erasure encoding, or bloom filter * creation should never be done in the context of the underlying node's * thread, and should only be done via this method. * * @param task The task to run on the processing thread * @param command The command to return the result to once it's done */ public void process(Executable task, Continuation command) { endpoint.process(task, command); } /** * Internal method which delivers the message to the application * * @param id The target id * @param target DESCRIBE THE PARAMETER */ protected void deliver(RingId id, Message target) { application.deliver(id, target); } /** * Passthrough to sub endpoint. * * @param handle DESCRIBE THE PARAMETER * @param receiver DESCRIBE THE PARAMETER * @param timeout DESCRIBE THE PARAMETER */ public void connect(NodeHandle handle, AppSocketReceiver receiver, int timeout) { MultiringNodeHandle mHandle = (MultiringNodeHandle) handle; endpoint.connect(mHandle.getHandle(), receiver, timeout); } /** * DESCRIBE THE METHOD * * @param receiver DESCRIBE THE PARAMETER */ public void accept(AppSocketReceiver receiver) { endpoint.accept(receiver); } /** * DESCRIBE THE METHOD * * @param buf DESCRIBE THE PARAMETER * @param type DESCRIBE THE PARAMETER * @return DESCRIBE THE RETURN VALUE * @exception IOException DESCRIBE THE EXCEPTION */ public Id readId(InputBuffer buf, short type) throws IOException { if (type == RingId.TYPE) { return new RingId(buf, endpoint); } return endpoint.readId(buf, type); } /** * DESCRIBE THE METHOD * * @param buf DESCRIBE THE PARAMETER * @return DESCRIBE THE RETURN VALUE * @exception IOException DESCRIBE THE EXCEPTION */ public NodeHandle readNodeHandle(InputBuffer buf) throws IOException { return new MultiringNodeHandle(buf, endpoint); } /** * DESCRIBE THE METHOD * * @param buf DESCRIBE THE PARAMETER * @return DESCRIBE THE RETURN VALUE * @exception IOException DESCRIBE THE EXCEPTION */ public IdRange readIdRange(InputBuffer buf) throws IOException { return new MultiringIdRange(buf, endpoint);// return endpoint.readIdRange(buf); } /** * DESCRIBE THE METHOD * * @param handle DESCRIBE THE PARAMETER * @return DESCRIBE THE RETURN VALUE */ public NodeHandle coalesce(NodeHandle handle) { if (handle instanceof MultiringNodeHandle) { MultiringNodeHandle mnh = (MultiringNodeHandle) handle; mnh.handle = endpoint.coalesce(mnh.handle); return mnh; } return endpoint.coalesce(handle); } /** * DESCRIBE THE METHOD * * @param buf DESCRIBE THE PARAMETER * @param type DESCRIBE THE PARAMETER * @return DESCRIBE THE RETURN VALUE * @exception IOException DESCRIBE THE EXCEPTION */ public NodeHandleSet readNodeHandleSet(InputBuffer buf, short type) throws IOException { switch (type) { case MultiringNodeHandleSet.TYPE: return new MultiringNodeHandleSet(buf, endpoint); } return endpoint.readNodeHandleSet(buf, type); } /** * DESCRIBE THE METHOD * * @return DESCRIBE THE RETURN VALUE */ public String toString() { return "MRE[" + endpoint + "]"; } /** * DESCRIBE THE METHOD */ public void register() { endpoint.register(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -