ServerCnxn.java 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.apache.zookeeper.server;
  19. import java.io.IOException;
  20. import java.net.InetSocketAddress;
  21. import java.nio.ByteBuffer;
  22. import java.util.ArrayList;
  23. import org.apache.jute.Record;
  24. import org.apache.zookeeper.Watcher;
  25. import org.apache.zookeeper.data.Id;
  26. import org.apache.zookeeper.proto.ReplyHeader;
  27. import org.apache.zookeeper.proto.WatcherEvent;
  28. public interface ServerCnxn extends Watcher {
  29. final static int killCmd = ByteBuffer.wrap("kill".getBytes()).getInt();
  30. final static int ruokCmd = ByteBuffer.wrap("ruok".getBytes()).getInt();
  31. final static int dumpCmd = ByteBuffer.wrap("dump".getBytes()).getInt();
  32. final static int statCmd = ByteBuffer.wrap("stat".getBytes()).getInt();
  33. final static int reqsCmd = ByteBuffer.wrap("reqs".getBytes()).getInt();
  34. final static int setTraceMaskCmd = ByteBuffer.wrap("stmk".getBytes())
  35. .getInt();
  36. final static int getTraceMaskCmd = ByteBuffer.wrap("gtmk".getBytes())
  37. .getInt();
  38. final static ByteBuffer imok = ByteBuffer.wrap("imok".getBytes());
  39. public abstract int getSessionTimeout();
  40. public abstract void close();
  41. public abstract void sendResponse(ReplyHeader h, Record r, String tag)
  42. throws IOException;
  43. public void finishSessionInit(boolean valid);
  44. public abstract void process(WatcherEvent event);
  45. public abstract long getSessionId();
  46. public abstract void setSessionId(long sessionId);
  47. public abstract ArrayList<Id> getAuthInfo();
  48. public InetSocketAddress getRemoteAddress();
  49. public interface Stats{
  50. public long getOutstandingRequests();
  51. public long getPacketsReceived();
  52. public long getPacketsSent();
  53. }
  54. public Stats getStats();
  55. }