{"id":199196,"date":"2013-10-27T22:16:02","date_gmt":"2013-10-27T18:16:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=199196"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=199196","title":{"rendered":"<span class=\"post_title\">\u0412\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 SUN\/ONCRPC \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 Java NIO<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412 <a href=\"http:\/\/habrahabr.ru\/post\/196584\/\">\u0441\u0442\u0430\u0442\u044ce<\/a> \u043e dCache \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 NFS \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0430 \u0432\u044b\u0441\u043e\u0442\u0435. \u0420\u0430\u0431\u043e\u0447\u0435\u0439 \u043b\u043e\u0448\u0430\u0434\u043a\u043e\u0439 NFS \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f ONCRPC \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b. \u0412 dCache \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430 <a href=\"https:\/\/grizzly.java.net\/\">grizzly nio framework<\/a>.<\/p>\n<h5>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0434\u043b\u044f \u043c\u043e\u043b\u043e\u0434\u044b\u0445<\/h5>\n<p>  ONC RPC (Open Network Computing Remote Procedure Call) \u2014 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 Sun Microsystems \u0432 \u043a\u043e\u043d\u0446\u0435 80\u0445 \u0438 <a href=\"http:\/\/tools.ietf.org\/html\/rfc1831\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d<\/a> \u0432 1995\u0433 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 NFSv2. ONCRPC \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f, \u043f\u043e\u043a\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 2000 \u043d\u0435 \u0431\u044b\u043b \u0432\u044b\u0442\u0435\u0441\u043d\u0435\u043d \u043c\u043e\u0434\u043d\u044b\u043c\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430\u043c\u0438, \u043a\u0430\u043a CORBA, SOAP, \u0430 \u043f\u043e\u0437\u0436\u0435 REST \u0438 JSON-RPC. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, ONCRPC \u0432\u0441\u0451 \u0435\u0449\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0433\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u0435\u0435 \u043c\u043e\u0434\u044b \u2014 \u0432 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445.<\/p>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <a href=\"http:\/\/remotetea.sourceforge.net\/\">Remote Tea<\/a>, \u043d\u043e \u0432\u0441\u043a\u043e\u0440\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0448\u0438\u0442\u044c: IPv6, GSSAPI, NIO. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c, \u043d\u043e \u043d\u0435 \u0441 \u043d\u0443\u043b\u044f. \u041c\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0441 RemoteTea \u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h5>Grizzly-NIO<\/h5>\n<p>  \u0412 \u043e\u0441\u043d\u043e\u0432\u0443 \u043c\u044b \u0432\u0437\u044f\u043b\u0438 grizzly-nio, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 glassfish. \u041a\u0430\u043a \u0438 \u0432\u0441\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 NIO \u0444\u0440\u0430\u0439\u043c\u0432\u043e\u0440\u043a\u0438, grizzly \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Chain-of-responsibility_pattern\">\u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439<\/a>. \u0422.\u0435., \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0446\u0435\u043f\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0438. <\/p>\n<pre><code class=\"java\">package org.glassfish.grizzly.filterchain;  import java.io.IOException;  public interface Filter {     public void onAdded(FilterChain fc);     public void onRemoved(FilterChain fc);     public void onFilterChainChanged(FilterChain fc);     public NextAction handleRead(FilterChainContext fcc) throws IOException;     public NextAction handleWrite(FilterChainContext fcc) throws IOException;     public NextAction handleConnect(FilterChainContext fcc) throws IOException;     public NextAction handleAccept(FilterChainContext fcc) throws IOException;     public NextAction handleEvent(FilterChainContext fcc, FilterChainEvent fce) throws IOException;     public NextAction handleClose(FilterChainContext fcc) throws IOException;     public void exceptionOccurred(FilterChainContext fcc, Throwable thrwbl); } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434\u044b handleXXXX \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 NextAction, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c StopAction \u0438\u043b\u0438 ContinueAction. \u0415\u0441\u043b\u0438 \u0444\u0438\u043b\u044c\u0442\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 StopAction, \u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 handleRead \u0438 handleWrite, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"java\">    @Override     public NextAction handleRead(FilterChainContext ctx) throws IOException {          Buffer messageBuffer = ctx.getMessage();         if (!isMessageArrived(messageBuffer)) {             \/\/ \u043f\u0440\u0438\u0448\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f             \/\/ \u0436\u0434\u0451\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c             return ctx.getStopAction(messageBuffer);         }         \/\/ \u0447\u0438\u0442\u0430\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435         ctx.setMessage(getMessage(messageBuffer));         return ctx.getInvokeAction();     } <\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0411\u043e\u0435\u0432\u043e\u0439 \u043a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">import java.io.IOException;  import java.nio.ByteOrder; import org.glassfish.grizzly.Buffer; import org.glassfish.grizzly.filterchain.BaseFilter; import org.glassfish.grizzly.filterchain.FilterChainContext; import org.glassfish.grizzly.filterchain.NextAction; import org.glassfish.grizzly.memory.BuffersBuffer;  public class RpcMessageParserTCP extends BaseFilter {      \/**      * RPC fragment record marker mask      *\/     private final static int RPC_LAST_FRAG = 0x80000000;     \/**      * RPC fragment size mask      *\/     private final static int RPC_SIZE_MASK = 0x7fffffff;      @Override     public NextAction handleRead(FilterChainContext ctx) throws IOException {          Buffer messageBuffer = ctx.getMessage();         if (messageBuffer == null) {             return ctx.getStopAction();         }          if (!isAllFragmentsArrived(messageBuffer)) {             return ctx.getStopAction(messageBuffer);         }          ctx.setMessage(assembleXdr(messageBuffer));          final Buffer reminder = messageBuffer.hasRemaining()                 ? messageBuffer.split(messageBuffer.position()) : null;          return ctx.getInvokeAction(reminder);     }      @Override     public NextAction handleWrite(FilterChainContext ctx) throws IOException {          Buffer b = ctx.getMessage();         int len = b.remaining() | RPC_LAST_FRAG;          Buffer marker = GrizzlyMemoryManager.allocate(4);         marker.order(ByteOrder.BIG_ENDIAN);         marker.putInt(len);         marker.flip();         marker.allowBufferDispose(true);         b.allowBufferDispose(true);         Buffer composite = GrizzlyMemoryManager.createComposite(marker, b);         composite.allowBufferDispose(true);         ctx.setMessage(composite);         return ctx.getInvokeAction();     }      private boolean isAllFragmentsArrived(Buffer messageBuffer) throws IOException {         final Buffer buffer = messageBuffer.duplicate();         buffer.order(ByteOrder.BIG_ENDIAN);          while (buffer.remaining() &gt;= 4) {              int messageMarker = buffer.getInt();             int size = getMessageSize(messageMarker);              \/*              * fragmen size bigger than we have received              *\/             if (size &gt; buffer.remaining()) {                 return false;             }              \/*              * complete fragment received              *\/             if (isLastFragment(messageMarker)) {                 return true;             }              \/*              * seek to the end of the current fragment              *\/             buffer.position(buffer.position() + size);         }          return false;     }      private static int getMessageSize(int marker) {         return marker & RPC_SIZE_MASK;     }      private static boolean isLastFragment(int marker) {         return (marker & RPC_LAST_FRAG) != 0;     }      private Xdr assembleXdr(Buffer messageBuffer) {          Buffer currentFragment;         BuffersBuffer multipleFragments = null;          boolean messageComplete;         do {             int messageMarker = messageBuffer.getInt();              int size = getMessageSize(messageMarker);             messageComplete = isLastFragment(messageMarker);              int pos = messageBuffer.position();             currentFragment = messageBuffer.slice(pos, pos + size);             currentFragment.limit(size);              messageBuffer.position(pos + size);             if (!messageComplete & multipleFragments == null) {                 \/*                  * we use composite buffer only if required                  * as they not for free.                  *\/                 multipleFragments = GrizzlyMemoryManager.create();             }              if (multipleFragments != null) {                 multipleFragments.append(currentFragment);             }         } while (!messageComplete);          return new Xdr(multipleFragments == null ? currentFragment : multipleFragments);     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0446\u0435\u043f\u044c \u0438\u0437-\u0437\u0430 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0437\u043e\u0432 handleRead \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0442\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440( \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432).<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a  <\/p>\n<pre><code class=\"java\">    public static void main(String[] args) throws IOException {          FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();         filterChainBuilder.add(new TransportFilter());         filterChainBuilder.add(new \/* \u0437\u0434\u0435\u0441\u044c \u043f\u0430\u0440\u0441\u0435\u0440 *\/);         filterChainBuilder.add(new \/* \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a *\/);          final TCPNIOTransport transport =                 TCPNIOTransportBuilder.newInstance().build();         transport.setProcessor(filterChainBuilder.build());         transport.bind(HOST, PORT);         transport.start();         System.in.read();     } <\/code><\/pre>\n<p>  \u041d\u0430 <a href=\"https:\/\/grizzly.java.net\/quickstart.html\">\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435<\/a> \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, grizzly \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0435\u0434\u043e\u0432, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u0430\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u0441\u0435\u0431\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u041d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0441 24 \u044f\u0434\u0440\u0430\u043c\u0438, \u043d\u0430\u0448 NFS \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043b\u0451\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0442\u044b\u0441\u044f\u0447\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  \u0421\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043a\u0430\u043a \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445, \u0442\u0430\u043a \u0438 \u043d\u0430 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u043c\u044b\u0435 \u043f\u0430\u0442\u0447\u0438 \u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438.<\/p>\n<h5>oncrpc4j<\/h5>\n<p>  \u0412\u0435\u0441\u044c ONCRPC \u043a\u043e\u0434 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u2014 \u0441\u0435\u0440\u0432\u0438\u0441, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043a\u0430\u043a Spring bean.<\/p>\n<h6>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h6>\n<p>  <\/p>\n<pre><code class=\"java\">import org.dcache.xdr.RpcDispatchable; import org.dcache.xdr.RpcCall; import org.dcache.xdr.XdrVoid; import org.dcache.xdr.OncRpcException;  public class Svcd {     private static final int DEFAULT_PORT = 1717;     private static final int PROG_NUMBER = 111017;     private static final int PROG_VERS = 1;      public static void main(String[] args) throws Exception {         RpcDispatchable dummy = new RpcDispatchable() {             @Override             public void dispatchOncRpcCall(RpcCall call)                           throws OncRpcException, IOException {                 call.reply(XdrVoid.XDR_VOID);             }         };         OncRpcSvc service = new OncRpcSvcBuilder()                 .withTCP()                 .withAutoPublish()                 .withPort(DEFAULT_PORT)                 .withSameThreadIoStrategy()                 .build();         service.register(new OncRpcProgram(PROG_NUMBER, PROG_VERS), dummy);         service.start();     } } <\/code><\/pre>\n<h6>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441\u043e Spring<\/h6>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u042f \u043d\u0435 \u0431\u043e\u044e\u0441\u044c XML<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;beans xmlns=&quot;http:\/\/www.springframework.org\/schema\/beans&quot;        xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;        xsi:schemaLocation=&quot;http:\/\/www.springframework.org\/schema\/beans        http:\/\/www.springframework.org\/schema\/beans\/spring-beans-2.5.xsd&quot;&gt;      &lt;bean id=&quot;my-rpc-svc&quot; class=&quot;me.mypackage.Svcd&quot;&gt;         &lt;description&gt;My RPC service&lt;\/description&gt;     &lt;\/bean&gt;       &lt;bean id=&quot;my-rpc&quot; class=&quot;org.dcache.xdr.OncRpcProgram&quot;&gt;         &lt;description&gt;My RPC program number&lt;\/description&gt;         &lt;constructor-arg index=&quot;0&quot; value=&quot;1110001&quot; \/&gt;         &lt;constructor-arg index=&quot;1&quot; value=&quot;1&quot; \/&gt;     &lt;\/bean&gt;      &lt;bean id=&quot;rpcsvc-builder&quot; class=&quot;org.dcache.xdr.OncRpcSvcFactoryBean&quot;&gt;         &lt;description&gt;Onc RPC service builder&lt;\/description&gt;         &lt;property name=&quot;port&quot; value=&quot;1717&quot;\/&gt;         &lt;property name=&quot;useTCP&quot; value=&quot;true&quot;\/&gt;     &lt;\/bean&gt;      &lt;bean id=&quot;oncrpcsvc&quot; class=&quot;org.dcache.xdr.OncRpcSvc&quot; init-method=&quot;start&quot; destroy-method=&quot;stop&quot;&gt;         &lt;description&gt;My RPC service&lt;\/description&gt;         &lt;constructor-arg ref=&quot;rpcsvc-builder&quot;\/&gt;         &lt;property name=&quot;programs&quot;&gt;             &lt;map&gt;                 &lt;entry key-ref=&quot;my-rpc&quot; value-ref=&quot;my-rpc-svc&quot;\/&gt;             &lt;\/map&gt;         &lt;\/property&gt;     &lt;\/bean&gt; &lt;\/beans&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h5>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h5>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/07a\/286\/757\/07a28675722fa25798ba806184496e3c.jpg\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0433\u0440\u0430\u0444\u0438\u043a\u0430, \u043a\u043e\u0434 \u043d\u0430 \u044f\u0432\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 &#8216;C&#8217;, \u043d\u043e \u0438 \u043e\u0431\u0433\u043e\u043d\u044f\u0435\u0442 \u043b\u0438\u043d\u0443\u043a\u0441\u043e\u0432\u0441\u043a\u043e\u0435 \u044f\u0434\u0440\u043e (\u0438\u0437-\u0437\u0430 \u0431\u0430\u0433\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0443\u0436\u0435 \u043f\u043e\u0447\u0438\u043d\u0438\u043b\u0438).<\/p>\n<h4>To steal and contribute code<\/h4>\n<p>  \u041a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/dCache\/oncrpc4j\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a> \u043f\u043e\u0434 LGPL \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0435\u0439.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/199196\/\"> http:\/\/habrahabr.ru\/post\/199196\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412 <a href=\"http:\/\/habrahabr.ru\/post\/196584\/\">\u0441\u0442\u0430\u0442\u044ce<\/a> \u043e dCache \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 NFS \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0430 \u0432\u044b\u0441\u043e\u0442\u0435. \u0420\u0430\u0431\u043e\u0447\u0435\u0439 \u043b\u043e\u0448\u0430\u0434\u043a\u043e\u0439 NFS \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f ONCRPC \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b. \u0412 dCache \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430 <a href=\"https:\/\/grizzly.java.net\/\">grizzly nio framework<\/a>.<\/p>\n<h5>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0434\u043b\u044f \u043c\u043e\u043b\u043e\u0434\u044b\u0445<\/h5>\n<p>  ONC RPC (Open Network Computing Remote Procedure Call) \u2014 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 Sun Microsystems \u0432 \u043a\u043e\u043d\u0446\u0435 80\u0445 \u0438 <a href=\"http:\/\/tools.ietf.org\/html\/rfc1831\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d<\/a> \u0432 1995\u0433 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 NFSv2. ONCRPC \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f, \u043f\u043e\u043a\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 2000 \u043d\u0435 \u0431\u044b\u043b \u0432\u044b\u0442\u0435\u0441\u043d\u0435\u043d \u043c\u043e\u0434\u043d\u044b\u043c\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430\u043c\u0438, \u043a\u0430\u043a CORBA, SOAP, \u0430 \u043f\u043e\u0437\u0436\u0435 REST \u0438 JSON-RPC. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, ONCRPC \u0432\u0441\u0451 \u0435\u0449\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0433\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u0435\u0435 \u043c\u043e\u0434\u044b \u2014 \u0432 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445.<\/p>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <a href=\"http:\/\/remotetea.sourceforge.net\/\">Remote Tea<\/a>, \u043d\u043e \u0432\u0441\u043a\u043e\u0440\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0448\u0438\u0442\u044c: IPv6, GSSAPI, NIO. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c, \u043d\u043e \u043d\u0435 \u0441 \u043d\u0443\u043b\u044f. \u041c\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0441 RemoteTea \u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-199196","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/199196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=199196"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/199196\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=199196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=199196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=199196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}