Skip to content

Commit

Permalink
KAA-749: Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvayka committed Jan 21, 2016
1 parent a4328d1 commit a5d40e0
Show file tree
Hide file tree
Showing 19 changed files with 178 additions and 314 deletions.
Expand Up @@ -34,9 +34,15 @@ public final class ClientSync {
/** The profile sync. */ /** The profile sync. */
private ProfileClientSync profileSync; private ProfileClientSync profileSync;


/** The force configuration sync flag */
private boolean forceConfigurationSync;

/** The configuration sync. */ /** The configuration sync. */
private ConfigurationClientSync configurationSync; private ConfigurationClientSync configurationSync;


/** The force notification sync flag */
private boolean forceNotificationSync;

/** The notification sync. */ /** The notification sync. */
private NotificationClientSync notificationSync; private NotificationClientSync notificationSync;


Expand Down Expand Up @@ -258,6 +264,23 @@ public boolean isValid() {
return true; return true;
} }


public boolean isForceConfigurationSync() {
return forceConfigurationSync;
}

public void setForceConfigurationSync(boolean forceConfigurationSync) {
this.forceConfigurationSync = forceConfigurationSync;
}

public boolean isForceNotificationSync() {
return forceNotificationSync;
}

public void setForceNotificationSync(boolean forceNotificationSync) {
this.forceNotificationSync = forceNotificationSync;
}


@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
Expand All @@ -266,6 +289,8 @@ public int hashCode() {
result = prime * result + ((clientSyncMetaData == null) ? 0 : clientSyncMetaData.hashCode()); result = prime * result + ((clientSyncMetaData == null) ? 0 : clientSyncMetaData.hashCode());
result = prime * result + ((configurationSync == null) ? 0 : configurationSync.hashCode()); result = prime * result + ((configurationSync == null) ? 0 : configurationSync.hashCode());
result = prime * result + ((eventSync == null) ? 0 : eventSync.hashCode()); result = prime * result + ((eventSync == null) ? 0 : eventSync.hashCode());
result = prime * result + (forceConfigurationSync ? 1231 : 1237);
result = prime * result + (forceNotificationSync ? 1231 : 1237);
result = prime * result + ((logSync == null) ? 0 : logSync.hashCode()); result = prime * result + ((logSync == null) ? 0 : logSync.hashCode());
result = prime * result + ((notificationSync == null) ? 0 : notificationSync.hashCode()); result = prime * result + ((notificationSync == null) ? 0 : notificationSync.hashCode());
result = prime * result + ((profileSync == null) ? 0 : profileSync.hashCode()); result = prime * result + ((profileSync == null) ? 0 : profileSync.hashCode());
Expand Down Expand Up @@ -303,6 +328,10 @@ public boolean equals(Object obj) {
return false; return false;
} else if (!eventSync.equals(other.eventSync)) } else if (!eventSync.equals(other.eventSync))
return false; return false;
if (forceConfigurationSync != other.forceConfigurationSync)
return false;
if (forceNotificationSync != other.forceNotificationSync)
return false;
if (logSync == null) { if (logSync == null) {
if (other.logSync != null) if (other.logSync != null)
return false; return false;
Expand Down Expand Up @@ -339,8 +368,12 @@ public String toString() {
builder.append(bootstrapSync); builder.append(bootstrapSync);
builder.append(", profileSync="); builder.append(", profileSync=");
builder.append(profileSync); builder.append(profileSync);
builder.append(", forceConfigurationSync=");
builder.append(forceConfigurationSync);
builder.append(", configurationSync="); builder.append(", configurationSync=");
builder.append(configurationSync); builder.append(configurationSync);
builder.append(", forceNotificationSync=");
builder.append(forceNotificationSync);
builder.append(", notificationSync="); builder.append(", notificationSync=");
builder.append(notificationSync); builder.append(notificationSync);
builder.append(", userSync="); builder.append(", userSync=");
Expand Down
Expand Up @@ -18,7 +18,6 @@
import java.nio.ByteBuffer; import java.nio.ByteBuffer;


public final class ConfigurationClientSync { public final class ConfigurationClientSync {
private int appStateSeqNumber;
private ByteBuffer configurationHash; private ByteBuffer configurationHash;
private boolean resyncOnly; private boolean resyncOnly;


Expand All @@ -28,29 +27,11 @@ public ConfigurationClientSync() {
/** /**
* All-args constructor. * All-args constructor.
*/ */
public ConfigurationClientSync(int appStateSeqNumber, ByteBuffer configurationHash, boolean resyncOnly) { public ConfigurationClientSync(ByteBuffer configurationHash, boolean resyncOnly) {
this.appStateSeqNumber = appStateSeqNumber;
this.configurationHash = configurationHash; this.configurationHash = configurationHash;
this.resyncOnly = resyncOnly; this.resyncOnly = resyncOnly;
} }


/**
* Gets the value of the 'appStateSeqNumber' field.
*/
public int getAppStateSeqNumber() {
return appStateSeqNumber;
}

/**
* Sets the value of the 'appStateSeqNumber' field.
*
* @param value
* the value to set.
*/
public void setAppStateSeqNumber(int value) {
this.appStateSeqNumber = value;
}

/** /**
* Gets the value of the 'configurationHash' field. * Gets the value of the 'configurationHash' field.
*/ */
Expand Down Expand Up @@ -90,7 +71,6 @@ public void setResyncOnly(boolean resyncOnly) {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + appStateSeqNumber;
result = prime * result + ((configurationHash == null) ? 0 : configurationHash.hashCode()); result = prime * result + ((configurationHash == null) ? 0 : configurationHash.hashCode());
result = prime * result + (resyncOnly ? 1231 : 1237); result = prime * result + (resyncOnly ? 1231 : 1237);
return result; return result;
Expand All @@ -108,9 +88,6 @@ public boolean equals(Object obj) {
return false; return false;
} }
ConfigurationClientSync other = (ConfigurationClientSync) obj; ConfigurationClientSync other = (ConfigurationClientSync) obj;
if (appStateSeqNumber != other.appStateSeqNumber) {
return false;
}
if (configurationHash == null) { if (configurationHash == null) {
if (other.configurationHash != null) { if (other.configurationHash != null) {
return false; return false;
Expand All @@ -127,9 +104,7 @@ public boolean equals(Object obj) {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("ConfigurationClientSync [appStateSeqNumber="); builder.append("ConfigurationClientSync [configurationHash=");
builder.append(appStateSeqNumber);
builder.append(", configurationHash=");
builder.append(configurationHash); builder.append(configurationHash);
builder.append(", resyncOnly="); builder.append(", resyncOnly=");
builder.append(resyncOnly); builder.append(resyncOnly);
Expand Down
Expand Up @@ -18,8 +18,7 @@
import java.util.List; import java.util.List;


public final class NotificationClientSync { public final class NotificationClientSync {
private int appStateSeqNumber; private int topicListHash;
private Integer topicListHash;
private List<TopicState> topicStates; private List<TopicState> topicStates;
private List<String> acceptedUnicastNotifications; private List<String> acceptedUnicastNotifications;
private List<SubscriptionCommand> subscriptionCommands; private List<SubscriptionCommand> subscriptionCommands;
Expand All @@ -30,38 +29,20 @@ public NotificationClientSync() {
/** /**
* All-args constructor. * All-args constructor.
*/ */
public NotificationClientSync(int appStateSeqNumber, Integer topicListHash, public NotificationClientSync(int topicListHash,
List<TopicState> topicStates, List<TopicState> topicStates,
List<String> acceptedUnicastNotifications, List<String> acceptedUnicastNotifications,
List<SubscriptionCommand> subscriptionCommands) { List<SubscriptionCommand> subscriptionCommands) {
this.appStateSeqNumber = appStateSeqNumber;
this.topicListHash = topicListHash; this.topicListHash = topicListHash;
this.topicStates = topicStates; this.topicStates = topicStates;
this.acceptedUnicastNotifications = acceptedUnicastNotifications; this.acceptedUnicastNotifications = acceptedUnicastNotifications;
this.subscriptionCommands = subscriptionCommands; this.subscriptionCommands = subscriptionCommands;
} }


/**
* Gets the value of the 'appStateSeqNumber' field.
*/
public int getAppStateSeqNumber() {
return appStateSeqNumber;
}

/**
* Sets the value of the 'appStateSeqNumber' field.
*
* @param value
* the value to set.
*/
public void setAppStateSeqNumber(int value) {
this.appStateSeqNumber = value;
}

/** /**
* Gets the value of the 'topicListHash' field. * Gets the value of the 'topicListHash' field.
*/ */
public Integer getTopicListHash() { public int getTopicListHash() {
return topicListHash; return topicListHash;
} }


Expand Down Expand Up @@ -125,9 +106,8 @@ public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((acceptedUnicastNotifications == null) ? 0 : acceptedUnicastNotifications.hashCode()); result = prime * result + ((acceptedUnicastNotifications == null) ? 0 : acceptedUnicastNotifications.hashCode());
result = prime * result + appStateSeqNumber;
result = prime * result + ((subscriptionCommands == null) ? 0 : subscriptionCommands.hashCode()); result = prime * result + ((subscriptionCommands == null) ? 0 : subscriptionCommands.hashCode());
result = prime * result + ((topicListHash == null) ? 0 : topicListHash.hashCode()); result = prime * result + topicListHash;
result = prime * result + ((topicStates == null) ? 0 : topicStates.hashCode()); result = prime * result + ((topicStates == null) ? 0 : topicStates.hashCode());
return result; return result;
} }
Expand All @@ -151,21 +131,14 @@ public boolean equals(Object obj) {
} else if (!acceptedUnicastNotifications.equals(other.acceptedUnicastNotifications)) { } else if (!acceptedUnicastNotifications.equals(other.acceptedUnicastNotifications)) {
return false; return false;
} }
if (appStateSeqNumber != other.appStateSeqNumber) {
return false;
}
if (subscriptionCommands == null) { if (subscriptionCommands == null) {
if (other.subscriptionCommands != null) { if (other.subscriptionCommands != null) {
return false; return false;
} }
} else if (!subscriptionCommands.equals(other.subscriptionCommands)) { } else if (!subscriptionCommands.equals(other.subscriptionCommands)) {
return false; return false;
} }
if (topicListHash == null) { if (topicListHash != other.topicListHash) {
if (other.topicListHash != null) {
return false;
}
} else if (!topicListHash.equals(other.topicListHash)) {
return false; return false;
} }
if (topicStates == null) { if (topicStates == null) {
Expand All @@ -181,9 +154,7 @@ public boolean equals(Object obj) {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("NotificationClientSync [appStateSeqNumber="); builder.append("NotificationClientSync [topicListHash=");
builder.append(appStateSeqNumber);
builder.append(", topicListHash=");
builder.append(topicListHash); builder.append(topicListHash);
builder.append(", topicStates="); builder.append(", topicStates=");
builder.append(topicStates); builder.append(topicStates);
Expand Down
Expand Up @@ -13,49 +13,32 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.kaaproject.kaa.server.sync; package org.kaaproject.kaa.server.sync;


import java.util.List; import java.util.List;


public final class NotificationServerSync { public final class NotificationServerSync {
private int appStateSeqNumber;
private SyncResponseStatus responseStatus; private SyncResponseStatus responseStatus;
private List<Notification> notifications; private List<Notification> notifications;
private List<Topic> availableTopics; private List<Topic> availableTopics;


/** /**
* Default constructor. Note that this does not initialize fields * Default constructor. Note that this does not initialize fields to their
* to their default values from the schema. If that is desired then * default values from the schema. If that is desired then one should use
* one should use {@link \#newBuilder()}. * {@link \#newBuilder()}.
*/ */
public NotificationServerSync() {} public NotificationServerSync() {
}


/** /**
* All-args constructor. * All-args constructor.
*/ */
public NotificationServerSync(java.lang.Integer appStateSeqNumber, SyncResponseStatus responseStatus, public NotificationServerSync(SyncResponseStatus responseStatus, List<Notification> notifications, List<Topic> availableTopics) {
List<Notification> notifications, List<Topic> availableTopics) {
this.appStateSeqNumber = appStateSeqNumber;
this.responseStatus = responseStatus; this.responseStatus = responseStatus;
this.notifications = notifications; this.notifications = notifications;
this.availableTopics = availableTopics; this.availableTopics = availableTopics;
} }


/**
* Gets the value of the 'appStateSeqNumber' field.
*/
public java.lang.Integer getAppStateSeqNumber() {
return appStateSeqNumber;
}

/**
* Sets the value of the 'appStateSeqNumber' field.
* @param value the value to set.
*/
public void setAppStateSeqNumber(java.lang.Integer value) {
this.appStateSeqNumber = value;
}

/** /**
* Gets the value of the 'responseStatus' field. * Gets the value of the 'responseStatus' field.
*/ */
Expand All @@ -65,7 +48,9 @@ public SyncResponseStatus getResponseStatus() {


/** /**
* Sets the value of the 'responseStatus' field. * Sets the value of the 'responseStatus' field.
* @param value the value to set. *
* @param value
* the value to set.
*/ */
public void setResponseStatus(SyncResponseStatus value) { public void setResponseStatus(SyncResponseStatus value) {
this.responseStatus = value; this.responseStatus = value;
Expand All @@ -80,7 +65,9 @@ public List<Notification> getNotifications() {


/** /**
* Sets the value of the 'notifications' field. * Sets the value of the 'notifications' field.
* @param value the value to set. *
* @param value
* the value to set.
*/ */
public void setNotifications(List<Notification> value) { public void setNotifications(List<Notification> value) {
this.notifications = value; this.notifications = value;
Expand All @@ -95,32 +82,36 @@ public List<Topic> getAvailableTopics() {


/** /**
* Sets the value of the 'availableTopics' field. * Sets the value of the 'availableTopics' field.
* @param value the value to set. *
* @param value
* the value to set.
*/ */
public void setAvailableTopics(List<Topic> value) { public void setAvailableTopics(List<Topic> value) {
this.availableTopics = value; this.availableTopics = value;
} }


@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o)
if (o == null || getClass() != o.getClass()) return false; return true;
if (o == null || getClass() != o.getClass())
return false;


NotificationServerSync that = (NotificationServerSync) o; NotificationServerSync that = (NotificationServerSync) o;


if (appStateSeqNumber != that.appStateSeqNumber) return false;
if (availableTopics != null ? !availableTopics.equals(that.availableTopics) : that.availableTopics != null) if (availableTopics != null ? !availableTopics.equals(that.availableTopics) : that.availableTopics != null)
return false; return false;
if (notifications != null ? !notifications.equals(that.notifications) : that.notifications != null) if (notifications != null ? !notifications.equals(that.notifications) : that.notifications != null)
return false; return false;
if (responseStatus != that.responseStatus) return false; if (responseStatus != that.responseStatus)
return false;


return true; return true;
} }


@Override @Override
public int hashCode() { public int hashCode() {
int result = appStateSeqNumber; int result = 1;
result = 31 * result + (responseStatus != null ? responseStatus.hashCode() : 0); result = 31 * result + (responseStatus != null ? responseStatus.hashCode() : 0);
result = 31 * result + (notifications != null ? notifications.hashCode() : 0); result = 31 * result + (notifications != null ? notifications.hashCode() : 0);
result = 31 * result + (availableTopics != null ? availableTopics.hashCode() : 0); result = 31 * result + (availableTopics != null ? availableTopics.hashCode() : 0);
Expand All @@ -130,9 +121,7 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("NotificationServerSync [appStateSeqNumber="); builder.append("NotificationServerSync [responseStatus=");
builder.append(appStateSeqNumber);
builder.append(", responseStatus=");
builder.append(responseStatus); builder.append(responseStatus);
builder.append(", notifications="); builder.append(", notifications=");
builder.append(notifications); builder.append(notifications);
Expand Down
Expand Up @@ -241,7 +241,6 @@ private static ConfigurationServerSync deepCopy(ConfigurationServerSync source)
return null; return null;
} }
ConfigurationServerSync copy = new ConfigurationServerSync(); ConfigurationServerSync copy = new ConfigurationServerSync();
copy.setAppStateSeqNumber(source.getAppStateSeqNumber());
copy.setResponseStatus(source.getResponseStatus()); copy.setResponseStatus(source.getResponseStatus());
copy.setConfDeltaBody(source.getConfDeltaBody()); copy.setConfDeltaBody(source.getConfDeltaBody());
copy.setConfSchemaBody(source.getConfSchemaBody()); copy.setConfSchemaBody(source.getConfSchemaBody());
Expand Down Expand Up @@ -285,7 +284,6 @@ private static NotificationServerSync deepCopy(NotificationServerSync source) {
return null; return null;
} }
NotificationServerSync copy = new NotificationServerSync(); NotificationServerSync copy = new NotificationServerSync();
copy.setAppStateSeqNumber(source.getAppStateSeqNumber());
copy.setResponseStatus(source.getResponseStatus()); copy.setResponseStatus(source.getResponseStatus());
if (source.getNotifications() != null) { if (source.getNotifications() != null) {
copy.setNotifications(new ArrayList<>(source.getNotifications())); copy.setNotifications(new ArrayList<>(source.getNotifications()));
Expand Down

0 comments on commit a5d40e0

Please sign in to comment.