zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1421781 - in /zookeeper/bookkeeper/trunk: ./ bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ bookke...
Date Fri, 14 Dec 2012 10:18:06 GMT
Author: ivank
Date: Fri Dec 14 10:18:04 2012
New Revision: 1421781

URL: http://svn.apache.org/viewvc?rev=1421781&view=rev
Log:
BOOKKEEPER-426: Make auditor Vote znode store a protobuf containing the host that voted (ivank)

Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/DataFormats.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/proto/DataFormats.proto

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1421781&r1=1421780&r2=1421781&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Fri Dec 14 10:18:04 2012
@@ -250,6 +250,8 @@ Trunk (unreleased changes)
 
         BOOKKEEPER-205: implement a MetaStore based ledger manager for bookkeeper client.
(jiannan via ivank)
 
+        BOOKKEEPER-426: Make auditor Vote znode store a protobuf containing the host that
voted (ivank)
+
       hedwig-server:
 
         BOOKKEEPER-250: Need a ledger manager like interface to manage metadata operations
in Hedwig (sijie via ivank)

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java?rev=1421781&r1=1421780&r2=1421781&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
Fri Dec 14 10:18:04 2012
@@ -38,10 +38,10 @@ import org.apache.zookeeper.ZooDefs.Ids;
 
 import com.google.protobuf.TextFormat;
 import com.google.common.base.Joiner;
+import static com.google.common.base.Charsets.UTF_8;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-import java.nio.charset.Charset;
 
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ConcurrentHashMap;
@@ -50,6 +50,7 @@ import java.util.List;
 import java.util.Collections;
 import java.util.Arrays;
 
+
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
 
@@ -73,7 +74,6 @@ import org.slf4j.LoggerFactory;
  */
 public class ZkLedgerUnderreplicationManager implements LedgerUnderreplicationManager {
     static final Logger LOG = LoggerFactory.getLogger(ZkLedgerUnderreplicationManager.class);
-    static final Charset UTF8 = Charset.forName("UTF-8");
     static final String LAYOUT="BASIC";
     static final int LAYOUT_VERSION=1;
 
@@ -139,7 +139,7 @@ public class ZkLedgerUnderreplicationMan
                     = LedgerRereplicationLayoutFormat.newBuilder();
                 builder.setType(LAYOUT).setVersion(LAYOUT_VERSION);
                 try {
-                    zkc.create(layoutZNode, TextFormat.printToString(builder.build()).getBytes(UTF8),
+                    zkc.create(layoutZNode, TextFormat.printToString(builder.build()).getBytes(UTF_8),
                                Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                 } catch (KeeperException.NodeExistsException nne) {
                     // someone else managed to create it
@@ -152,7 +152,7 @@ public class ZkLedgerUnderreplicationMan
                     = LedgerRereplicationLayoutFormat.newBuilder();
 
                 try {
-                    TextFormat.merge(new String(layoutData, UTF8), builder);
+                    TextFormat.merge(new String(layoutData, UTF_8), builder);
                     LedgerRereplicationLayoutFormat layout = builder.build();
                     if (!layout.getType().equals(LAYOUT)
                             || layout.getVersion() != LAYOUT_VERSION) {
@@ -217,7 +217,7 @@ public class ZkLedgerUnderreplicationMan
                 try {
                     builder.addReplica(missingReplica);
                     ZkUtils.createFullPathOptimistic(zkc, znode, TextFormat
-                            .printToString(builder.build()).getBytes(UTF8),
+                            .printToString(builder.build()).getBytes(UTF_8),
                             Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                 } catch (KeeperException.NodeExistsException nee) {
                     Stat s = zkc.exists(znode, false);
@@ -227,14 +227,14 @@ public class ZkLedgerUnderreplicationMan
                     try {
                         byte[] bytes = zkc.getData(znode, false, s);
                         builder.clear();
-                        TextFormat.merge(new String(bytes, UTF8), builder);
+                        TextFormat.merge(new String(bytes, UTF_8), builder);
                         UnderreplicatedLedgerFormat data = builder.build();
                         if (data.getReplicaList().contains(missingReplica)) {
                             return; // nothing to add
                         }
                         builder.addReplica(missingReplica);
                         zkc.setData(znode,
-                                    TextFormat.printToString(builder.build()).getBytes(UTF8),
+                                    TextFormat.printToString(builder.build()).getBytes(UTF_8),
                                     s.getVersion());
                     } catch (KeeperException.NoNodeException nne) {
                         continue;
@@ -329,7 +329,7 @@ public class ZkLedgerUnderreplicationMan
                     }
 
                     long ledgerId = getLedgerId(tryChild);
-                    zkc.create(lockPath, TextFormat.printToString(lockData).getBytes(UTF8),
+                    zkc.create(lockPath, TextFormat.printToString(lockData).getBytes(UTF_8),
                                Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
                     heldLocks.put(ledgerId, new Lock(lockPath, stat.getVersion()));
                     return ledgerId;

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/DataFormats.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/DataFormats.java?rev=1421781&r1=1421780&r2=1421781&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/DataFormats.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/DataFormats.java
Fri Dec 14 10:18:04 2012
@@ -3574,6 +3574,381 @@ public final class DataFormats {
     // @@protoc_insertion_point(class_scope:LockDataFormat)
   }
   
+  public interface AuditorVoteFormatOrBuilder
+      extends com.google.protobuf.MessageOrBuilder {
+    
+    // optional string bookieId = 1;
+    boolean hasBookieId();
+    String getBookieId();
+  }
+  public static final class AuditorVoteFormat extends
+      com.google.protobuf.GeneratedMessage
+      implements AuditorVoteFormatOrBuilder {
+    // Use AuditorVoteFormat.newBuilder() to construct.
+    private AuditorVoteFormat(Builder builder) {
+      super(builder);
+    }
+    private AuditorVoteFormat(boolean noInit) {}
+    
+    private static final AuditorVoteFormat defaultInstance;
+    public static AuditorVoteFormat getDefaultInstance() {
+      return defaultInstance;
+    }
+    
+    public AuditorVoteFormat getDefaultInstanceForType() {
+      return defaultInstance;
+    }
+    
+    public static final com.google.protobuf.Descriptors.Descriptor
+        getDescriptor() {
+      return org.apache.bookkeeper.proto.DataFormats.internal_static_AuditorVoteFormat_descriptor;
+    }
+    
+    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+        internalGetFieldAccessorTable() {
+      return org.apache.bookkeeper.proto.DataFormats.internal_static_AuditorVoteFormat_fieldAccessorTable;
+    }
+    
+    private int bitField0_;
+    // optional string bookieId = 1;
+    public static final int BOOKIEID_FIELD_NUMBER = 1;
+    private java.lang.Object bookieId_;
+    public boolean hasBookieId() {
+      return ((bitField0_ & 0x00000001) == 0x00000001);
+    }
+    public String getBookieId() {
+      java.lang.Object ref = bookieId_;
+      if (ref instanceof String) {
+        return (String) ref;
+      } else {
+        com.google.protobuf.ByteString bs = 
+            (com.google.protobuf.ByteString) ref;
+        String s = bs.toStringUtf8();
+        if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+          bookieId_ = s;
+        }
+        return s;
+      }
+    }
+    private com.google.protobuf.ByteString getBookieIdBytes() {
+      java.lang.Object ref = bookieId_;
+      if (ref instanceof String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+        bookieId_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+    
+    private void initFields() {
+      bookieId_ = "";
+    }
+    private byte memoizedIsInitialized = -1;
+    public final boolean isInitialized() {
+      byte isInitialized = memoizedIsInitialized;
+      if (isInitialized != -1) return isInitialized == 1;
+      
+      memoizedIsInitialized = 1;
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.CodedOutputStream output)
+                        throws java.io.IOException {
+      getSerializedSize();
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        output.writeBytes(1, getBookieIdBytes());
+      }
+      getUnknownFields().writeTo(output);
+    }
+    
+    private int memoizedSerializedSize = -1;
+    public int getSerializedSize() {
+      int size = memoizedSerializedSize;
+      if (size != -1) return size;
+    
+      size = 0;
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeBytesSize(1, getBookieIdBytes());
+      }
+      size += getUnknownFields().getSerializedSize();
+      memoizedSerializedSize = size;
+      return size;
+    }
+    
+    private static final long serialVersionUID = 0L;
+    @java.lang.Override
+    protected java.lang.Object writeReplace()
+        throws java.io.ObjectStreamException {
+      return super.writeReplace();
+    }
+    
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseFrom(
+        com.google.protobuf.ByteString data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return newBuilder().mergeFrom(data).buildParsed();
+    }
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseFrom(
+        com.google.protobuf.ByteString data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return newBuilder().mergeFrom(data, extensionRegistry)
+               .buildParsed();
+    }
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseFrom(byte[]
data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return newBuilder().mergeFrom(data).buildParsed();
+    }
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseFrom(
+        byte[] data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return newBuilder().mergeFrom(data, extensionRegistry)
+               .buildParsed();
+    }
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseFrom(java.io.InputStream
input)
+        throws java.io.IOException {
+      return newBuilder().mergeFrom(input).buildParsed();
+    }
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return newBuilder().mergeFrom(input, extensionRegistry)
+               .buildParsed();
+    }
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseDelimitedFrom(java.io.InputStream
input)
+        throws java.io.IOException {
+      Builder builder = newBuilder();
+      if (builder.mergeDelimitedFrom(input)) {
+        return builder.buildParsed();
+      } else {
+        return null;
+      }
+    }
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseDelimitedFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      Builder builder = newBuilder();
+      if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+        return builder.buildParsed();
+      } else {
+        return null;
+      }
+    }
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseFrom(
+        com.google.protobuf.CodedInputStream input)
+        throws java.io.IOException {
+      return newBuilder().mergeFrom(input).buildParsed();
+    }
+    public static org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat parseFrom(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return newBuilder().mergeFrom(input, extensionRegistry)
+               .buildParsed();
+    }
+    
+    public static Builder newBuilder() { return Builder.create(); }
+    public Builder newBuilderForType() { return newBuilder(); }
+    public static Builder newBuilder(org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat
prototype) {
+      return newBuilder().mergeFrom(prototype);
+    }
+    public Builder toBuilder() { return newBuilder(this); }
+    
+    @java.lang.Override
+    protected Builder newBuilderForType(
+        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+      Builder builder = new Builder(parent);
+      return builder;
+    }
+    public static final class Builder extends
+        com.google.protobuf.GeneratedMessage.Builder<Builder>
+       implements org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormatOrBuilder {
+      public static final com.google.protobuf.Descriptors.Descriptor
+          getDescriptor() {
+        return org.apache.bookkeeper.proto.DataFormats.internal_static_AuditorVoteFormat_descriptor;
+      }
+      
+      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+          internalGetFieldAccessorTable() {
+        return org.apache.bookkeeper.proto.DataFormats.internal_static_AuditorVoteFormat_fieldAccessorTable;
+      }
+      
+      // Construct using org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat.newBuilder()
+      private Builder() {
+        maybeForceBuilderInitialization();
+      }
+      
+      private Builder(BuilderParent parent) {
+        super(parent);
+        maybeForceBuilderInitialization();
+      }
+      private void maybeForceBuilderInitialization() {
+        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+        }
+      }
+      private static Builder create() {
+        return new Builder();
+      }
+      
+      public Builder clear() {
+        super.clear();
+        bookieId_ = "";
+        bitField0_ = (bitField0_ & ~0x00000001);
+        return this;
+      }
+      
+      public Builder clone() {
+        return create().mergeFrom(buildPartial());
+      }
+      
+      public com.google.protobuf.Descriptors.Descriptor
+          getDescriptorForType() {
+        return org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat.getDescriptor();
+      }
+      
+      public org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat getDefaultInstanceForType()
{
+        return org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat.getDefaultInstance();
+      }
+      
+      public org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat build() {
+        org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat result = buildPartial();
+        if (!result.isInitialized()) {
+          throw newUninitializedMessageException(result);
+        }
+        return result;
+      }
+      
+      private org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat buildParsed()
+          throws com.google.protobuf.InvalidProtocolBufferException {
+        org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat result = buildPartial();
+        if (!result.isInitialized()) {
+          throw newUninitializedMessageException(
+            result).asInvalidProtocolBufferException();
+        }
+        return result;
+      }
+      
+      public org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat buildPartial() {
+        org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat result = new org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat(this);
+        int from_bitField0_ = bitField0_;
+        int to_bitField0_ = 0;
+        if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+          to_bitField0_ |= 0x00000001;
+        }
+        result.bookieId_ = bookieId_;
+        result.bitField0_ = to_bitField0_;
+        onBuilt();
+        return result;
+      }
+      
+      public Builder mergeFrom(com.google.protobuf.Message other) {
+        if (other instanceof org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat) {
+          return mergeFrom((org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat)other);
+        } else {
+          super.mergeFrom(other);
+          return this;
+        }
+      }
+      
+      public Builder mergeFrom(org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat
other) {
+        if (other == org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat.getDefaultInstance())
return this;
+        if (other.hasBookieId()) {
+          setBookieId(other.getBookieId());
+        }
+        this.mergeUnknownFields(other.getUnknownFields());
+        return this;
+      }
+      
+      public final boolean isInitialized() {
+        return true;
+      }
+      
+      public Builder mergeFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws java.io.IOException {
+        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+          com.google.protobuf.UnknownFieldSet.newBuilder(
+            this.getUnknownFields());
+        while (true) {
+          int tag = input.readTag();
+          switch (tag) {
+            case 0:
+              this.setUnknownFields(unknownFields.build());
+              onChanged();
+              return this;
+            default: {
+              if (!parseUnknownField(input, unknownFields,
+                                     extensionRegistry, tag)) {
+                this.setUnknownFields(unknownFields.build());
+                onChanged();
+                return this;
+              }
+              break;
+            }
+            case 10: {
+              bitField0_ |= 0x00000001;
+              bookieId_ = input.readBytes();
+              break;
+            }
+          }
+        }
+      }
+      
+      private int bitField0_;
+      
+      // optional string bookieId = 1;
+      private java.lang.Object bookieId_ = "";
+      public boolean hasBookieId() {
+        return ((bitField0_ & 0x00000001) == 0x00000001);
+      }
+      public String getBookieId() {
+        java.lang.Object ref = bookieId_;
+        if (!(ref instanceof String)) {
+          String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+          bookieId_ = s;
+          return s;
+        } else {
+          return (String) ref;
+        }
+      }
+      public Builder setBookieId(String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000001;
+        bookieId_ = value;
+        onChanged();
+        return this;
+      }
+      public Builder clearBookieId() {
+        bitField0_ = (bitField0_ & ~0x00000001);
+        bookieId_ = getDefaultInstance().getBookieId();
+        onChanged();
+        return this;
+      }
+      void setBookieId(com.google.protobuf.ByteString value) {
+        bitField0_ |= 0x00000001;
+        bookieId_ = value;
+        onChanged();
+      }
+      
+      // @@protoc_insertion_point(builder_scope:AuditorVoteFormat)
+    }
+    
+    static {
+      defaultInstance = new AuditorVoteFormat(true);
+      defaultInstance.initFields();
+    }
+    
+    // @@protoc_insertion_point(class_scope:AuditorVoteFormat)
+  }
+  
   private static com.google.protobuf.Descriptors.Descriptor
     internal_static_LedgerMetadataFormat_descriptor;
   private static
@@ -3604,6 +3979,11 @@ public final class DataFormats {
   private static
     com.google.protobuf.GeneratedMessage.FieldAccessorTable
       internal_static_LockDataFormat_fieldAccessorTable;
+  private static com.google.protobuf.Descriptors.Descriptor
+    internal_static_AuditorVoteFormat_descriptor;
+  private static
+    com.google.protobuf.GeneratedMessage.FieldAccessorTable
+      internal_static_AuditorVoteFormat_fieldAccessorTable;
   
   public static com.google.protobuf.Descriptors.FileDescriptor
       getDescriptor() {
@@ -3630,8 +4010,9 @@ public final class DataFormats {
       "erFormat\022\017\n\007replica\030\001 \003(\t\"^\n\014CookieForma" +
       "t\022\022\n\nbookieHost\030\001 \002(\t\022\022\n\njournalDir\030\002 \002(" +
       "\t\022\022\n\nledgerDirs\030\003 \002(\t\022\022\n\ninstanceId\030\004 \001(" +
-      "\t\"\"\n\016LockDataFormat\022\020\n\010bookieId\030\001 \001(\tB\037\n" +
-      "\033org.apache.bookkeeper.protoH\001"
+      "\t\"\"\n\016LockDataFormat\022\020\n\010bookieId\030\001 \001(\t\"%\n" +
+      "\021AuditorVoteFormat\022\020\n\010bookieId\030\001 \001(\tB\037\n\033" +
+      "org.apache.bookkeeper.protoH\001"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
       new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -3686,6 +4067,14 @@ public final class DataFormats {
               new java.lang.String[] { "BookieId", },
               org.apache.bookkeeper.proto.DataFormats.LockDataFormat.class,
               org.apache.bookkeeper.proto.DataFormats.LockDataFormat.Builder.class);
+          internal_static_AuditorVoteFormat_descriptor =
+            getDescriptor().getMessageTypes().get(5);
+          internal_static_AuditorVoteFormat_fieldAccessorTable = new
+            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+              internal_static_AuditorVoteFormat_descriptor,
+              new java.lang.String[] { "BookieId", },
+              org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat.class,
+              org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat.Builder.class);
           return null;
         }
       };

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java?rev=1421781&r1=1421780&r2=1421781&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
Fri Dec 14 10:18:04 2012
@@ -25,6 +25,7 @@ import java.util.Comparator;
 import java.util.List;
 import java.io.Serializable;
 
+import org.apache.bookkeeper.proto.DataFormats.AuditorVoteFormat;
 import org.apache.bookkeeper.conf.AbstractConfiguration;
 import org.apache.bookkeeper.replication.ReplicationException.UnavailableException;
 import org.apache.bookkeeper.util.BookKeeperConstants;
@@ -36,6 +37,9 @@ import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.Watcher.Event.EventType;
 import org.apache.zookeeper.ZooDefs.Ids;
+import com.google.protobuf.TextFormat;
+import static com.google.common.base.Charsets.UTF_8;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -122,7 +126,10 @@ public class AuditorElector {
             if (children.get(AUDITOR_INDEX).equals(voteNode)) {
                 // update the auditor bookie id in the election path. This is
                 // done for debugging purpose
-                zkc.setData(getVotePath(""), bookieId.getBytes(), -1);
+                AuditorVoteFormat.Builder builder = AuditorVoteFormat.newBuilder()
+                    .setBookieId(bookieId);
+
+                zkc.setData(getVotePath(""), TextFormat.printToString(builder.build()).getBytes(UTF_8),
-1);
                 auditor = new Auditor(bookieId, conf, zkc);
                 auditor.start();
             } else {
@@ -150,8 +157,10 @@ public class AuditorElector {
 
     private void createMyVote() throws KeeperException, InterruptedException {
         if (null == myVote || null == zkc.exists(myVote, false)) {
+            AuditorVoteFormat.Builder builder = AuditorVoteFormat.newBuilder()
+                .setBookieId(bookieId);
             myVote = zkc.create(getVotePath(PATH_SEPARATOR + VOTE_PREFIX),
-                    bookieId.getBytes(), Ids.OPEN_ACL_UNSAFE,
+                    TextFormat.printToString(builder.build()).getBytes(UTF_8), Ids.OPEN_ACL_UNSAFE,
                     CreateMode.EPHEMERAL_SEQUENTIAL);
         }
     }

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/proto/DataFormats.proto
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/proto/DataFormats.proto?rev=1421781&r1=1421780&r2=1421781&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/proto/DataFormats.proto (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/proto/DataFormats.proto Fri Dec
14 10:18:04 2012
@@ -74,4 +74,11 @@ message CookieFormat {
  */
 message LockDataFormat {
     optional string bookieId = 1;
+}
+
+/**
+ * Debug information for auditor votes
+ */
+message AuditorVoteFormat {
+    optional string bookieId = 1;
 }
\ No newline at end of file



Mime
View raw message