diff --git a/build.xml b/build.xml index c6a555e692a..89d5f580dbb 100644 --- a/build.xml +++ b/build.xml @@ -25,7 +25,7 @@ - + @@ -138,6 +138,8 @@ + + @@ -248,7 +250,7 @@ - + @@ -267,7 +269,7 @@ + includes="org/apache/jute/**" debug="on" classpath="${ivy.lib}/audience-annotations-${audience-annotations.version}.jar" /> @@ -334,9 +336,9 @@ - + + target="${javac.target}" source="${javac.source}" debug="on" classpath="${ivy.lib}/audience-annotations-${audience-annotations.version}.jar" /> @@ -487,23 +489,24 @@ windowtitle="${Name} ${version} API" doctitle="${Name} ${version} API" bottom="Copyright &copy; ${year} The Apache Software Foundation" + doclet="org.apache.yetus.audience.tools.IncludePublicAnnotationsStandardDoclet" + docletpath="${ivy.lib}/audience-annotations-${audience-annotations.version}.jar" > - - - - - - - - - - + + + + - - - + + + + + + + + @@ -713,7 +716,7 @@ - + @@ -728,7 +731,7 @@ - + @@ -801,7 +804,7 @@ - + @@ -836,7 +839,7 @@ + tofile="${dist.maven.dir}/${final.name}-test.jar"/> - + @@ -1495,7 +1498,7 @@ - @@ -1510,17 +1513,17 @@ - - + - + diff --git a/cloudera/maven-packaging/zookeeper/pom.xml b/cloudera/maven-packaging/zookeeper/pom.xml index 74ed88052c1..da21bf8258e 100644 --- a/cloudera/maven-packaging/zookeeper/pom.xml +++ b/cloudera/maven-packaging/zookeeper/pom.xml @@ -63,6 +63,12 @@ ${cdh.netty.version} compile + + org.apache.yetus + audience-annotations + 0.5.0 + compile + junit junit diff --git a/ivy.xml b/ivy.xml index 93b983808fa..7bb8ef0e41c 100644 --- a/ivy.xml +++ b/ivy.xml @@ -46,6 +46,8 @@ + + diff --git a/src/java/main/org/apache/jute/Record.java b/src/java/main/org/apache/jute/Record.java index bc7a350eeaf..d955280578d 100644 --- a/src/java/main/org/apache/jute/Record.java +++ b/src/java/main/org/apache/jute/Record.java @@ -18,12 +18,15 @@ package org.apache.jute; +import org.apache.yetus.audience.InterfaceAudience; + import java.io.IOException; /** * Interface that is implemented by generated classes. * */ +@InterfaceAudience.Public public interface Record { public void serialize(OutputArchive archive, String tag) throws IOException; diff --git a/src/java/main/org/apache/jute/compiler/JRecord.java b/src/java/main/org/apache/jute/compiler/JRecord.java index 01ba2989afb..e1c5cfb8638 100644 --- a/src/java/main/org/apache/jute/compiler/JRecord.java +++ b/src/java/main/org/apache/jute/compiler/JRecord.java @@ -426,6 +426,8 @@ public void genJavaCode(File outputDirectory) throws IOException { jj.write("\n"); jj.write("package "+getJavaPackage()+";\n\n"); jj.write("import org.apache.jute.*;\n"); + jj.write("import org.apache.yetus.audience.InterfaceAudience;\n"); + jj.write("@InterfaceAudience.Public\n"); jj.write("public class "+getName()+" implements Record {\n"); for (Iterator i = mFields.iterator(); i.hasNext();) { JField jf = i.next(); @@ -599,7 +601,7 @@ public void genCsharpCode(File outputDirectory) throws IOException { cs.write("\n"); cs.write("using System;\n"); cs.write("using Org.Apache.Jute;\n"); - cs.write("\n"); + cs.write("\n"); cs.write("namespace "+getCsharpNameSpace()+"\n"); cs.write("{\n"); diff --git a/src/java/main/org/apache/zookeeper/AsyncCallback.java b/src/java/main/org/apache/zookeeper/AsyncCallback.java index 30377238b5d..c5b507d4737 100644 --- a/src/java/main/org/apache/zookeeper/AsyncCallback.java +++ b/src/java/main/org/apache/zookeeper/AsyncCallback.java @@ -19,38 +19,47 @@ import java.util.List; +import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.data.ACL; import org.apache.zookeeper.data.Stat; +@InterfaceAudience.Public public interface AsyncCallback { + @InterfaceAudience.Public interface StatCallback extends AsyncCallback { public void processResult(int rc, String path, Object ctx, Stat stat); } - + + @InterfaceAudience.Public interface DataCallback extends AsyncCallback { public void processResult(int rc, String path, Object ctx, byte data[], Stat stat); } - + + @InterfaceAudience.Public interface ACLCallback extends AsyncCallback { public void processResult(int rc, String path, Object ctx, List acl, Stat stat); } - + + @InterfaceAudience.Public interface ChildrenCallback extends AsyncCallback { public void processResult(int rc, String path, Object ctx, List children); } - + + @InterfaceAudience.Public interface Children2Callback extends AsyncCallback { public void processResult(int rc, String path, Object ctx, List children, Stat stat); } - + + @InterfaceAudience.Public interface StringCallback extends AsyncCallback { public void processResult(int rc, String path, Object ctx, String name); } - + + @InterfaceAudience.Public interface VoidCallback extends AsyncCallback { public void processResult(int rc, String path, Object ctx); } diff --git a/src/java/main/org/apache/zookeeper/CreateMode.java b/src/java/main/org/apache/zookeeper/CreateMode.java index 6e9c89a0160..54e9ae62638 100644 --- a/src/java/main/org/apache/zookeeper/CreateMode.java +++ b/src/java/main/org/apache/zookeeper/CreateMode.java @@ -17,6 +17,7 @@ */ package org.apache.zookeeper; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.zookeeper.KeeperException; @@ -24,6 +25,7 @@ /*** * CreateMode value determines how the znode is created on ZooKeeper. */ +@InterfaceAudience.Public public enum CreateMode { /** diff --git a/src/java/main/org/apache/zookeeper/KeeperException.java b/src/java/main/org/apache/zookeeper/KeeperException.java index 2664411d36b..5f8d0e29043 100644 --- a/src/java/main/org/apache/zookeeper/KeeperException.java +++ b/src/java/main/org/apache/zookeeper/KeeperException.java @@ -18,6 +18,8 @@ package org.apache.zookeeper; +import org.apache.yetus.audience.InterfaceAudience; + import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; @@ -25,6 +27,7 @@ import java.util.Map; @SuppressWarnings("serial") +@InterfaceAudience.Public public abstract class KeeperException extends Exception { /** * All multi-requests that result in an exception retain the results @@ -163,6 +166,7 @@ public void setCode(int code) { * javadoc to include in the user API spec. */ @Deprecated + @InterfaceAudience.Public public interface CodeDeprecated { /** * @deprecated deprecated in 3.1.0, use {@link Code#OK} instead @@ -288,6 +292,7 @@ public interface CodeDeprecated { * constants. The old, deprecated, values are in "camel case" while the new * enum values are in all CAPS. */ + @InterfaceAudience.Public public static enum Code implements CodeDeprecated { /** Everything is OK */ OK (Ok), @@ -482,7 +487,7 @@ void setMultiResults(List results) { * If this exception was thrown by a multi-request then the (partial) results * and error codes can be retrieved using this getter. * @return A copy of the list of results from the operations in the multi-request. - * + * * @since 3.4.0 * */ @@ -493,6 +498,7 @@ public List getResults() { /** * @see Code#APIERROR */ + @InterfaceAudience.Public public static class APIErrorException extends KeeperException { public APIErrorException() { super(Code.APIERROR); @@ -502,6 +508,7 @@ public APIErrorException() { /** * @see Code#AUTHFAILED */ + @InterfaceAudience.Public public static class AuthFailedException extends KeeperException { public AuthFailedException() { super(Code.AUTHFAILED); @@ -511,6 +518,7 @@ public AuthFailedException() { /** * @see Code#BADARGUMENTS */ + @InterfaceAudience.Public public static class BadArgumentsException extends KeeperException { public BadArgumentsException() { super(Code.BADARGUMENTS); @@ -523,6 +531,7 @@ public BadArgumentsException(String path) { /** * @see Code#BADVERSION */ + @InterfaceAudience.Public public static class BadVersionException extends KeeperException { public BadVersionException() { super(Code.BADVERSION); @@ -535,6 +544,7 @@ public BadVersionException(String path) { /** * @see Code#CONNECTIONLOSS */ + @InterfaceAudience.Public public static class ConnectionLossException extends KeeperException { public ConnectionLossException() { super(Code.CONNECTIONLOSS); @@ -544,6 +554,7 @@ public ConnectionLossException() { /** * @see Code#DATAINCONSISTENCY */ + @InterfaceAudience.Public public static class DataInconsistencyException extends KeeperException { public DataInconsistencyException() { super(Code.DATAINCONSISTENCY); @@ -553,6 +564,7 @@ public DataInconsistencyException() { /** * @see Code#INVALIDACL */ + @InterfaceAudience.Public public static class InvalidACLException extends KeeperException { public InvalidACLException() { super(Code.INVALIDACL); @@ -565,6 +577,7 @@ public InvalidACLException(String path) { /** * @see Code#INVALIDCALLBACK */ + @InterfaceAudience.Public public static class InvalidCallbackException extends KeeperException { public InvalidCallbackException() { super(Code.INVALIDCALLBACK); @@ -574,6 +587,7 @@ public InvalidCallbackException() { /** * @see Code#MARSHALLINGERROR */ + @InterfaceAudience.Public public static class MarshallingErrorException extends KeeperException { public MarshallingErrorException() { super(Code.MARSHALLINGERROR); @@ -583,6 +597,7 @@ public MarshallingErrorException() { /** * @see Code#NOAUTH */ + @InterfaceAudience.Public public static class NoAuthException extends KeeperException { public NoAuthException() { super(Code.NOAUTH); @@ -592,6 +607,7 @@ public NoAuthException() { /** * @see Code#NOCHILDRENFOREPHEMERALS */ + @InterfaceAudience.Public public static class NoChildrenForEphemeralsException extends KeeperException { public NoChildrenForEphemeralsException() { super(Code.NOCHILDRENFOREPHEMERALS); @@ -604,6 +620,7 @@ public NoChildrenForEphemeralsException(String path) { /** * @see Code#NODEEXISTS */ + @InterfaceAudience.Public public static class NodeExistsException extends KeeperException { public NodeExistsException() { super(Code.NODEEXISTS); @@ -616,6 +633,7 @@ public NodeExistsException(String path) { /** * @see Code#NONODE */ + @InterfaceAudience.Public public static class NoNodeException extends KeeperException { public NoNodeException() { super(Code.NONODE); @@ -628,6 +646,7 @@ public NoNodeException(String path) { /** * @see Code#NOTEMPTY */ + @InterfaceAudience.Public public static class NotEmptyException extends KeeperException { public NotEmptyException() { super(Code.NOTEMPTY); @@ -640,6 +659,7 @@ public NotEmptyException(String path) { /** * @see Code#OPERATIONTIMEOUT */ + @InterfaceAudience.Public public static class OperationTimeoutException extends KeeperException { public OperationTimeoutException() { super(Code.OPERATIONTIMEOUT); @@ -649,6 +669,7 @@ public OperationTimeoutException() { /** * @see Code#RUNTIMEINCONSISTENCY */ + @InterfaceAudience.Public public static class RuntimeInconsistencyException extends KeeperException { public RuntimeInconsistencyException() { super(Code.RUNTIMEINCONSISTENCY); @@ -658,6 +679,7 @@ public RuntimeInconsistencyException() { /** * @see Code#SESSIONEXPIRED */ + @InterfaceAudience.Public public static class SessionExpiredException extends KeeperException { public SessionExpiredException() { super(Code.SESSIONEXPIRED); @@ -667,6 +689,7 @@ public SessionExpiredException() { /** * @see Code#SESSIONMOVED */ + @InterfaceAudience.Public public static class SessionMovedException extends KeeperException { public SessionMovedException() { super(Code.SESSIONMOVED); @@ -676,6 +699,7 @@ public SessionMovedException() { /** * @see Code#NOTREADONLY */ + @InterfaceAudience.Public public static class NotReadOnlyException extends KeeperException { public NotReadOnlyException() { super(Code.NOTREADONLY); @@ -685,6 +709,7 @@ public NotReadOnlyException() { /** * @see Code#SYSTEMERROR */ + @InterfaceAudience.Public public static class SystemErrorException extends KeeperException { public SystemErrorException() { super(Code.SYSTEMERROR); @@ -694,6 +719,7 @@ public SystemErrorException() { /** * @see Code#UNIMPLEMENTED */ + @InterfaceAudience.Public public static class UnimplementedException extends KeeperException { public UnimplementedException() { super(Code.UNIMPLEMENTED); diff --git a/src/java/main/org/apache/zookeeper/ServerAdminClient.java b/src/java/main/org/apache/zookeeper/ServerAdminClient.java index da17fcfcb55..4fc6c7ad419 100644 --- a/src/java/main/org/apache/zookeeper/ServerAdminClient.java +++ b/src/java/main/org/apache/zookeeper/ServerAdminClient.java @@ -26,11 +26,13 @@ import java.nio.ByteBuffer; import java.util.StringTokenizer; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.zookeeper.server.ZooTrace; +@InterfaceAudience.Public public class ServerAdminClient { private static final Logger LOG = LoggerFactory.getLogger(ServerAdminClient.class); diff --git a/src/java/main/org/apache/zookeeper/Transaction.java b/src/java/main/org/apache/zookeeper/Transaction.java index 7e67b87a4c1..17196e04cc7 100644 --- a/src/java/main/org/apache/zookeeper/Transaction.java +++ b/src/java/main/org/apache/zookeeper/Transaction.java @@ -17,6 +17,7 @@ package org.apache.zookeeper; +import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.data.ACL; import java.util.ArrayList; import java.util.List; @@ -28,6 +29,7 @@ * @since 3.4.0 * */ +@InterfaceAudience.Public public class Transaction { private ZooKeeper zk; private List ops = new ArrayList(); diff --git a/src/java/main/org/apache/zookeeper/WatchedEvent.java b/src/java/main/org/apache/zookeeper/WatchedEvent.java index 63f29c3c631..851fc6c8567 100644 --- a/src/java/main/org/apache/zookeeper/WatchedEvent.java +++ b/src/java/main/org/apache/zookeeper/WatchedEvent.java @@ -17,6 +17,7 @@ */ package org.apache.zookeeper; +import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.proto.WatcherEvent; import org.apache.zookeeper.Watcher.Event.EventType; import org.apache.zookeeper.Watcher.Event.KeeperState; @@ -27,6 +28,7 @@ * the current state of the ZooKeeper, and the path of the znode that * was involved in the event. */ +@InterfaceAudience.Public public class WatchedEvent { final private KeeperState keeperState; final private EventType eventType; diff --git a/src/java/main/org/apache/zookeeper/Watcher.java b/src/java/main/org/apache/zookeeper/Watcher.java index 36c7b5b8d39..3eca42ade23 100644 --- a/src/java/main/org/apache/zookeeper/Watcher.java +++ b/src/java/main/org/apache/zookeeper/Watcher.java @@ -18,6 +18,8 @@ package org.apache.zookeeper; +import org.apache.yetus.audience.InterfaceAudience; + /** * This interface specifies the public interface an event handler class must * implement. A ZooKeeper client will get various events from the ZooKeepr @@ -26,15 +28,18 @@ * is expected to be an instance of a class that implements Watcher interface. * */ +@InterfaceAudience.Public public interface Watcher { /** * This interface defines the possible states an Event may represent */ + @InterfaceAudience.Public public interface Event { /** * Enumeration of states the ZooKeeper may be at the event */ + @InterfaceAudience.Public public enum KeeperState { /** Unused, this state is never generated by the server */ @Deprecated @@ -112,6 +117,7 @@ public static KeeperState fromInt(int intValue) { /** * Enumeration of types of events that may occur on the ZooKeeper */ + @InterfaceAudience.Public public enum EventType { None (-1), NodeCreated (1), diff --git a/src/java/main/org/apache/zookeeper/ZooDefs.java b/src/java/main/org/apache/zookeeper/ZooDefs.java index c7f1b208c36..09bc95c3693 100644 --- a/src/java/main/org/apache/zookeeper/ZooDefs.java +++ b/src/java/main/org/apache/zookeeper/ZooDefs.java @@ -21,10 +21,14 @@ import java.util.ArrayList; import java.util.Collections; +import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.data.ACL; import org.apache.zookeeper.data.Id; +@InterfaceAudience.Public public class ZooDefs { + + @InterfaceAudience.Public public interface OpCode { public final int notification = 0; @@ -67,6 +71,7 @@ public interface OpCode { public final int error = -1; } + @InterfaceAudience.Public public interface Perms { int READ = 1 << 0; @@ -81,6 +86,7 @@ public interface Perms { int ALL = READ | WRITE | CREATE | DELETE | ADMIN; } + @InterfaceAudience.Public public interface Ids { /** * This Id represents anyone. diff --git a/src/java/main/org/apache/zookeeper/ZooKeeper.java b/src/java/main/org/apache/zookeeper/ZooKeeper.java index 86c619d8d01..cb5b69ccefd 100644 --- a/src/java/main/org/apache/zookeeper/ZooKeeper.java +++ b/src/java/main/org/apache/zookeeper/ZooKeeper.java @@ -18,6 +18,7 @@ package org.apache.zookeeper; +import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.AsyncCallback.*; import org.apache.zookeeper.OpResult.ErrorResult; import org.apache.zookeeper.client.ConnectStringParser; @@ -83,6 +84,7 @@ * EventNone and state sKeeperStateDisconnected. * */ +@InterfaceAudience.Public public class ZooKeeper { public static final String ZOOKEEPER_CLIENT_CNXN_SOCKET = "zookeeper.clientCnxnSocket"; @@ -313,6 +315,7 @@ protected Map> getWatches(int rc) { } } + @InterfaceAudience.Public public enum States { CONNECTING, ASSOCIATING, CONNECTED, CONNECTEDREADONLY, CLOSED, AUTH_FAILED, NOT_CONNECTED; diff --git a/src/java/main/org/apache/zookeeper/ZooKeeperMain.java b/src/java/main/org/apache/zookeeper/ZooKeeperMain.java index 2ebd6052e99..d0afeaf8c0f 100644 --- a/src/java/main/org/apache/zookeeper/ZooKeeperMain.java +++ b/src/java/main/org/apache/zookeeper/ZooKeeperMain.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.NoSuchElementException; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.zookeeper.AsyncCallback.DataCallback; @@ -46,6 +47,7 @@ * The command line client to ZooKeeper. * */ +@InterfaceAudience.Public public class ZooKeeperMain { private static final Logger LOG = LoggerFactory.getLogger(ZooKeeperMain.class); protected static final Map commandMap = new HashMap( ); @@ -667,9 +669,9 @@ protected boolean processZKCmd(MyCommandOptions co) if (args.length >=2) { connectToZK(args[1]); } else { - connectToZK(host); + connectToZK(host); } - } + } // Below commands all need a live connection if (zk == null || !zk.getState().isAlive()) { @@ -743,7 +745,7 @@ protected boolean processZKCmd(MyCommandOptions co) path = args[1]; stat = zk.exists(path, watch); if (stat == null) { - throw new KeeperException.NoNodeException(path); + throw new KeeperException.NoNodeException(path); } printStat(stat); } else if (cmd.equals("listquota") && args.length >= 2) { @@ -803,7 +805,7 @@ protected boolean processZKCmd(MyCommandOptions co) usage(); } } else if (cmd.equals("close")) { - zk.close(); + zk.close(); } else if (cmd.equals("sync") && args.length >= 2) { path = args[1]; zk.sync(path, new AsyncCallback.VoidCallback() { public void processResult(int rc, String path, Object ctx) { System.out.println("Sync returned " + rc); } }, null ); diff --git a/src/java/main/org/apache/zookeeper/client/FourLetterWordMain.java b/src/java/main/org/apache/zookeeper/client/FourLetterWordMain.java index e41465ab93a..c14a6cb915d 100644 --- a/src/java/main/org/apache/zookeeper/client/FourLetterWordMain.java +++ b/src/java/main/org/apache/zookeeper/client/FourLetterWordMain.java @@ -26,6 +26,9 @@ import java.io.OutputStream; import java.net.Socket; +import org.apache.yetus.audience.InterfaceAudience; + +@InterfaceAudience.Public public class FourLetterWordMain { protected static final Logger LOG = Logger.getLogger(FourLetterWordMain.class); diff --git a/src/java/main/org/apache/zookeeper/client/HostProvider.java b/src/java/main/org/apache/zookeeper/client/HostProvider.java index c2815b3e7be..490dc32b458 100644 --- a/src/java/main/org/apache/zookeeper/client/HostProvider.java +++ b/src/java/main/org/apache/zookeeper/client/HostProvider.java @@ -18,6 +18,8 @@ package org.apache.zookeeper.client; +import org.apache.yetus.audience.InterfaceAudience; + import java.net.InetSocketAddress; /** @@ -39,6 +41,7 @@ * * A HostProvider that re-resolves the InetSocketAddress after a timeout. * * A HostProvider that prefers nearby hosts. */ +@InterfaceAudience.Public public interface HostProvider { public int size(); diff --git a/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java b/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java index 959fe89f5f5..64dba795a34 100644 --- a/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java +++ b/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java @@ -26,6 +26,7 @@ import java.util.Collections; import java.util.List; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +35,7 @@ * Most simple HostProvider, resolves only on instantiation. * */ +@InterfaceAudience.Public public final class StaticHostProvider implements HostProvider { private static final Logger LOG = LoggerFactory .getLogger(StaticHostProvider.class); diff --git a/src/java/main/org/apache/zookeeper/server/LogFormatter.java b/src/java/main/org/apache/zookeeper/server/LogFormatter.java index cd1347d91db..c5274e58947 100644 --- a/src/java/main/org/apache/zookeeper/server/LogFormatter.java +++ b/src/java/main/org/apache/zookeeper/server/LogFormatter.java @@ -30,6 +30,7 @@ import org.apache.jute.BinaryInputArchive; import org.apache.jute.InputArchive; import org.apache.jute.Record; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.zookeeper.server.persistence.FileHeader; @@ -37,6 +38,7 @@ import org.apache.zookeeper.server.util.SerializeUtils; import org.apache.zookeeper.txn.TxnHeader; +@InterfaceAudience.Public public class LogFormatter { private static final Logger LOG = LoggerFactory.getLogger(LogFormatter.class); diff --git a/src/java/main/org/apache/zookeeper/server/PurgeTxnLog.java b/src/java/main/org/apache/zookeeper/server/PurgeTxnLog.java index 185c1e123cf..73a8eea8898 100644 --- a/src/java/main/org/apache/zookeeper/server/PurgeTxnLog.java +++ b/src/java/main/org/apache/zookeeper/server/PurgeTxnLog.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Set; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.zookeeper.server.persistence.FileTxnSnapLog; @@ -41,6 +42,7 @@ * files and snapdir files keeping the last "-n" snapshot files * and the corresponding logs. */ +@InterfaceAudience.Public public class PurgeTxnLog { private static final Logger LOG = LoggerFactory.getLogger(PurgeTxnLog.class); @@ -53,7 +55,7 @@ static void printUsage(){ } /** - * purges the snapshot and logs keeping the last num snapshots + * purges the snapshot and logs keeping the last num snapshots * and the corresponding logs. * @param dataDir the dir that has the logs * @param snapDir the dir that has the snapshots @@ -72,7 +74,7 @@ public static void purge(File dataDir, File snapDir, int num) throws IOException // files to exclude from deletion Set exc=new HashSet(); List snaps = txnLog.findNRecentSnapshots(num); - if (snaps.size() == 0) + if (snaps.size() == 0) return; File snapShot = snaps.get(snaps.size() -1); for (File f: snaps) { diff --git a/src/java/main/org/apache/zookeeper/server/ServerConfig.java b/src/java/main/org/apache/zookeeper/server/ServerConfig.java index ec710cd3a15..9e1e03742f5 100644 --- a/src/java/main/org/apache/zookeeper/server/ServerConfig.java +++ b/src/java/main/org/apache/zookeeper/server/ServerConfig.java @@ -21,6 +21,7 @@ import java.net.InetSocketAddress; import java.util.Arrays; +import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.server.quorum.QuorumPeerConfig; import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; @@ -30,6 +31,7 @@ * We use this instead of Properties as it's typed. * */ +@InterfaceAudience.Public public class ServerConfig { //// //// If you update the configuration parameters be sure diff --git a/src/java/main/org/apache/zookeeper/server/SnapshotFormatter.java b/src/java/main/org/apache/zookeeper/server/SnapshotFormatter.java index 0ecab73d051..b920bf06ac8 100644 --- a/src/java/main/org/apache/zookeeper/server/SnapshotFormatter.java +++ b/src/java/main/org/apache/zookeeper/server/SnapshotFormatter.java @@ -1,128 +1,130 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.zookeeper.server; - -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.zip.Adler32; -import java.util.zip.CheckedInputStream; - -import org.apache.jute.BinaryInputArchive; -import org.apache.jute.InputArchive; -import org.apache.zookeeper.data.StatPersisted; -import org.apache.zookeeper.server.persistence.FileSnap; - -/** - * Dump a snapshot file to stdout. - */ -public class SnapshotFormatter { - - /** - * USAGE: SnapshotFormatter snapshot_file - */ - public static void main(String[] args) throws Exception { - if (args.length != 1) { - System.err.println("USAGE: SnapshotFormatter snapshot_file"); - System.exit(2); - } - - new SnapshotFormatter().run(args[0]); - } - - public void run(String snapshotFileName) throws IOException { - InputStream is = new CheckedInputStream( - new BufferedInputStream(new FileInputStream(snapshotFileName)), - new Adler32()); - InputArchive ia = BinaryInputArchive.getArchive(is); - - FileSnap fileSnap = new FileSnap(null); - - DataTree dataTree = new DataTree(); - Map sessions = new HashMap(); - - fileSnap.deserialize(dataTree, sessions, ia); - - printDetails(dataTree, sessions); - } - - private void printDetails(DataTree dataTree, Map sessions) { - printZnodeDetails(dataTree); - printSessionDetails(dataTree, sessions); - } - - private void printZnodeDetails(DataTree dataTree) { - System.out.println(String.format("ZNode Details (count=%d):", - dataTree.getNodeCount())); - - printZnode(dataTree, "/"); - System.out.println("----"); - } - - private void printZnode(DataTree dataTree, String name) { - System.out.println("----"); - DataNode n = dataTree.getNode(name); - Set children; - synchronized(n) { // keep findbugs happy - System.out.println(name); - printStat(n.stat); - if (n.data != null) { - System.out.println(" dataLength = " + n.data.length); - } else { - System.out.println(" no data"); - } - children = n.getChildren(); - } - if (children != null) { - for (String child : children) { - printZnode(dataTree, name + (name.equals("/") ? "" : "/") + child); - } - } - } - - private void printSessionDetails(DataTree dataTree, Map sessions) { - System.out.println("Session Details (sid, timeout, ephemeralCount):"); - for (Map.Entry e : sessions.entrySet()) { - long sid = e.getKey(); - System.out.println(String.format("%#016x, %d, %d", - sid, e.getValue(), dataTree.getEphemerals(sid).size())); - } - } - - private void printStat(StatPersisted stat) { - printHex("cZxid", stat.getCzxid()); - System.out.println(" ctime = " + new Date(stat.getCtime()).toString()); - printHex("mZxid", stat.getMzxid()); - System.out.println(" mtime = " + new Date(stat.getMtime()).toString()); - printHex("pZxid", stat.getPzxid()); - System.out.println(" cversion = " + stat.getCversion()); - System.out.println(" dataVersion = " + stat.getVersion()); - System.out.println(" aclVersion = " + stat.getAversion()); - printHex("ephemeralOwner", stat.getEphemeralOwner()); - } - - private void printHex(String prefix, long value) { - System.out.println(String.format(" %s = %#016x", prefix, value)); - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.zookeeper.server; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.zip.Adler32; +import java.util.zip.CheckedInputStream; + +import org.apache.jute.BinaryInputArchive; +import org.apache.jute.InputArchive; +import org.apache.yetus.audience.InterfaceAudience; +import org.apache.zookeeper.data.StatPersisted; +import org.apache.zookeeper.server.persistence.FileSnap; + +/** + * Dump a snapshot file to stdout. + */ +@InterfaceAudience.Public +public class SnapshotFormatter { + + /** + * USAGE: SnapshotFormatter snapshot_file + */ + public static void main(String[] args) throws Exception { + if (args.length != 1) { + System.err.println("USAGE: SnapshotFormatter snapshot_file"); + System.exit(2); + } + + new SnapshotFormatter().run(args[0]); + } + + public void run(String snapshotFileName) throws IOException { + InputStream is = new CheckedInputStream( + new BufferedInputStream(new FileInputStream(snapshotFileName)), + new Adler32()); + InputArchive ia = BinaryInputArchive.getArchive(is); + + FileSnap fileSnap = new FileSnap(null); + + DataTree dataTree = new DataTree(); + Map sessions = new HashMap(); + + fileSnap.deserialize(dataTree, sessions, ia); + + printDetails(dataTree, sessions); + } + + private void printDetails(DataTree dataTree, Map sessions) { + printZnodeDetails(dataTree); + printSessionDetails(dataTree, sessions); + } + + private void printZnodeDetails(DataTree dataTree) { + System.out.println(String.format("ZNode Details (count=%d):", + dataTree.getNodeCount())); + + printZnode(dataTree, "/"); + System.out.println("----"); + } + + private void printZnode(DataTree dataTree, String name) { + System.out.println("----"); + DataNode n = dataTree.getNode(name); + Set children; + synchronized(n) { // keep findbugs happy + System.out.println(name); + printStat(n.stat); + if (n.data != null) { + System.out.println(" dataLength = " + n.data.length); + } else { + System.out.println(" no data"); + } + children = n.getChildren(); + } + if (children != null) { + for (String child : children) { + printZnode(dataTree, name + (name.equals("/") ? "" : "/") + child); + } + } + } + + private void printSessionDetails(DataTree dataTree, Map sessions) { + System.out.println("Session Details (sid, timeout, ephemeralCount):"); + for (Map.Entry e : sessions.entrySet()) { + long sid = e.getKey(); + System.out.println(String.format("%#016x, %d, %d", + sid, e.getValue(), dataTree.getEphemerals(sid).size())); + } + } + + private void printStat(StatPersisted stat) { + printHex("cZxid", stat.getCzxid()); + System.out.println(" ctime = " + new Date(stat.getCtime()).toString()); + printHex("mZxid", stat.getMzxid()); + System.out.println(" mtime = " + new Date(stat.getMtime()).toString()); + printHex("pZxid", stat.getPzxid()); + System.out.println(" cversion = " + stat.getCversion()); + System.out.println(" dataVersion = " + stat.getVersion()); + System.out.println(" aclVersion = " + stat.getAversion()); + printHex("ephemeralOwner", stat.getEphemeralOwner()); + } + + private void printHex(String prefix, long value) { + System.out.println(String.format(" %s = %#016x", prefix, value)); + } +} diff --git a/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java b/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java index 9d09cdbe543..b0d5d5c12ac 100644 --- a/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java +++ b/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java @@ -23,6 +23,7 @@ import javax.management.JMException; +import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.jmx.ManagedUtil; import org.apache.zookeeper.server.persistence.FileTxnSnapLog; import org.apache.zookeeper.server.persistence.FileTxnSnapLog.DatadirException; @@ -33,6 +34,7 @@ /** * This class starts and runs a standalone ZooKeeperServer. */ +@InterfaceAudience.Public public class ZooKeeperServerMain { private static final Logger LOG = LoggerFactory.getLogger(ZooKeeperServerMain.class); diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java b/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java index be0a410ba7d..27c8ef3f79f 100644 --- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java +++ b/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java @@ -31,6 +31,7 @@ import java.util.Properties; import java.util.Map.Entry; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -42,6 +43,7 @@ import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier; +@InterfaceAudience.Public public class QuorumPeerConfig { private static final Logger LOG = LoggerFactory.getLogger(QuorumPeerConfig.class); @@ -338,7 +340,7 @@ public void parseProperties(Properties zkProp) // Now add observers to servers, once the quorums have been // figured out servers.putAll(observers); - + File myIdFile = new File(dataDir, "myid"); if (!myIdFile.exists()) { throw new IllegalArgumentException(myIdFile.toString() @@ -383,7 +385,7 @@ public void parseProperties(Properties zkProp) public int getInitLimit() { return initLimit; } public int getSyncLimit() { return syncLimit; } public int getElectionAlg() { return electionAlg; } - public int getElectionPort() { return electionPort; } + public int getElectionPort() { return electionPort; } public int getSnapRetainCount() { return snapRetainCount; @@ -393,7 +395,7 @@ public int getPurgeInterval() { return purgeInterval; } - public QuorumVerifier getQuorumVerifier() { + public QuorumVerifier getQuorumVerifier() { return quorumVerifier; } diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java b/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java index 029fa9637c2..3248df25104 100644 --- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java +++ b/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java @@ -22,6 +22,7 @@ import javax.management.JMException; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.zookeeper.jmx.ManagedUtil; @@ -61,6 +62,7 @@ * "myid" that contains the server id as an ASCII decimal value. * */ +@InterfaceAudience.Public public class QuorumPeerMain { private static final Logger LOG = LoggerFactory.getLogger(QuorumPeerMain.class); diff --git a/src/java/main/org/apache/zookeeper/server/upgrade/UpgradeMain.java b/src/java/main/org/apache/zookeeper/server/upgrade/UpgradeMain.java index 779c4818714..eff1fe4db7e 100644 --- a/src/java/main/org/apache/zookeeper/server/upgrade/UpgradeMain.java +++ b/src/java/main/org/apache/zookeeper/server/upgrade/UpgradeMain.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.zookeeper.server.DataTree; @@ -36,6 +37,7 @@ * it creates a backup in the dataDir/.bkup and snapShotDir/.bkup which * can be retrieved back to the snapShotDir and dataDir */ +@InterfaceAudience.Public public class UpgradeMain { File snapShotDir; File dataDir;