/*
 * Copyright 2015 the original author or authors.
 *
 * Licensed 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 net.kuujo.copycat.raft.log.entry;

import net.kuujo.copycat.cluster.MemberInfo;
import net.kuujo.copycat.io.serializer.SerializeWith;
import net.kuujo.copycat.io.util.ReferenceManager;

/**
 * Register client entry.
 *
 * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
 */
@SerializeWith(id=1006)
public class RegisterEntry extends TimestampedEntry<RegisterEntry> {
  private MemberInfo member;

  public RegisterEntry() {
  }

  public RegisterEntry(ReferenceManager<Entry<?>> referenceManager) {
    super(referenceManager);
  }

  /**
   * Returns the member info.
   *
   * @return The member info.
   */
  public MemberInfo getMember() {
    return member;
  }

  /**
   * Sets the member info.
   *
   * @param info The member info.
   * @return The register entry.
   */
  public RegisterEntry setMember(MemberInfo info) {
    this.member = info;
    return this;
  }

  @Override
  public String toString() {
    return String.format("%s[index=%d, member=%s, timestamp=%d]", getClass().getSimpleName(), getIndex(), member, getTimestamp());
  }

}

@@ -724,32 +724,119 @@
 .io.
-serializer.SerializeWith
+Buffer;%0Aimport net.kuujo.copycat.io.serializer.SerializeWith;%0Aimport net.kuujo.copycat.io.serializer.Serializer
 ;%0Aim
@@ -1432,20 +1432,22 @@
  @param 
-info
+member
  The mem
@@ -1539,20 +1539,22 @@
 berInfo 
-info
+member
 ) %7B%0A    
@@ -1567,20 +1567,22 @@
 ember = 
-info
+member
 ;%0A    re
@@ -1597,16 +1597,354 @@
 s;%0A  %7D%0A%0A
+  @Override%0A  public void writeObject(Buffer buffer, Serializer serializer) %7B%0A    super.writeObject(buffer, serializer);%0A    serializer.writeObject(member, buffer);%0A  %7D%0A%0A  @Override%0A  public void readObject(Buffer buffer, Serializer serializer) %7B%0A    super.readObject(buffer, serializer);%0A    member = serializer.readObject(buffer);%0A  %7D%0A%0A
   @Overr

Handle serialization of member info in register entries.