@Override public void serialize(Applications applications, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeStartObject(); jgen.writeStringField(versionDeltaKey, applications.getVersion().toString()); jgen.writeStringField(appHashCodeKey, applications.getAppsHashCode()); jgen.writeObjectField(NODE_APP, applications.getRegisteredApplications()); } }
@Override protected void serializeFields(Object bean, JsonGenerator jgen0, SerializerProvider provider) throws IOException { super.serializeFields(bean, jgen0, provider); Applications applications = (Applications) bean; if (applications.getVersion() != null) { jgen0.writeStringField(versionKey, Long.toString(applications.getVersion())); } if (applications.getAppsHashCode() != null) { jgen0.writeStringField(appsHashCodeKey, applications.getAppsHashCode()); } } }
@Override protected void serializeFields(Object bean, JsonGenerator jgen0, SerializerProvider provider) throws IOException { super.serializeFields(bean, jgen0, provider); Applications applications = (Applications) bean; if (applications.getVersion() != null) { jgen0.writeStringField(versionKey, Long.toString(applications.getVersion())); } if (applications.getAppsHashCode() != null) { jgen0.writeStringField(appsHashCodeKey, applications.getAppsHashCode()); } } }
getApplications().setVersion(delta.getVersion()); logger.debug( "The Reconcile hashcodes after complete sync up, client : {}, server : {}.",
|| (applications == null) || (applications.getRegisteredApplications().size() == 0) || (applications.getVersion() == -1)) //Client application does not have latest library supporting delta logger.info("Registered Applications size is zero : {}", (applications.getRegisteredApplications().size() == 0)); logger.info("Application version is -1: {}", (applications.getVersion() == -1)); getAndStoreFullRegistry(); } else {
@Test public void testApplicationsHashAndVersion() { Applications applications = new Applications("appsHashCode", 1L, Collections.emptyList()); assertEquals(1L, (long)applications.getVersion()); assertEquals("appsHashCode", applications.getAppsHashCode()); }
@Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Applications apps = (Applications) source; writer.startNode(VERSIONS_DELTA); writer.setValue(apps.getVersion().toString()); writer.endNode(); writer.startNode(APPS_HASHCODE); writer.setValue(apps.getAppsHashCode()); writer.endNode(); for (Application app : apps.getRegisteredApplications()) { writer.startNode(NODE_APP); context.convertAnother(app); writer.endNode(); } }
@Test public void testVersionAndAppHash() { Applications apps = new Applications(); assertEquals(-1L, (long)apps.getVersion()); assertNull(apps.getAppsHashCode()); apps.setVersion(101L); apps.setAppsHashCode("UP_5_DOWN_6_"); assertEquals(101L, (long)apps.getVersion()); assertEquals("UP_5_DOWN_6_", apps.getAppsHashCode()); }
getApplications().setVersion(delta.getVersion()); getApplications().shuffleInstances(clientConfig.shouldFilterOnlyUpInstances()); applications.setVersion(delta.getVersion()); applications.shuffleInstances(clientConfig.shouldFilterOnlyUpInstances());
@Override public void serialize(Applications applications, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeStartObject(); jgen.writeStringField(versionDeltaKey, applications.getVersion().toString()); jgen.writeStringField(appHashCodeKey, applications.getAppsHashCode()); jgen.writeObjectField(NODE_APP, applications.getRegisteredApplications()); } }
@Override protected void serializeFields(Object bean, JsonGenerator jgen0, SerializerProvider provider) throws IOException { super.serializeFields(bean, jgen0, provider); Applications applications = (Applications) bean; if (applications.getVersion() != null) { jgen0.writeStringField(versionKey, Long.toString(applications.getVersion())); } if (applications.getAppsHashCode() != null) { jgen0.writeStringField(appsHashCodeKey, applications.getAppsHashCode()); } } }
@Override protected void serializeFields(Object bean, JsonGenerator jgen0, SerializerProvider provider) throws IOException { super.serializeFields(bean, jgen0, provider); Applications applications = (Applications) bean; if (applications.getVersion() != null) { jgen0.writeStringField(versionKey, Long.toString(applications.getVersion())); } if (applications.getAppsHashCode() != null) { jgen0.writeStringField(appsHashCodeKey, applications.getAppsHashCode()); } } }
|| (applications == null) || (applications.getRegisteredApplications().size() == 0) || (applications.getVersion() == -1)) //Client application does not have latest library supporting delta logger.info("Registered Applications size is zero : {}", (applications.getRegisteredApplications().size() == 0)); logger.info("Application version is -1: {}", (applications.getVersion() == -1)); getAndStoreFullRegistry(); } else {
getApplications().setVersion(delta.getVersion()); logger.debug( "The Reconcile hashcodes after complete sync up, client : {}, server : {}.",
@Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Applications apps = (Applications) source; writer.startNode(VERSIONS_DELTA); writer.setValue(apps.getVersion().toString()); writer.endNode(); writer.startNode(APPS_HASHCODE); writer.setValue(apps.getAppsHashCode()); writer.endNode(); for (Application app : apps.getRegisteredApplications()) { writer.startNode(NODE_APP); context.convertAnother(app); writer.endNode(); } }
getApplications().setVersion(delta.getVersion()); getApplications().shuffleInstances(clientConfig.shouldFilterOnlyUpInstances()); applications.setVersion(delta.getVersion()); applications.shuffleInstances(clientConfig.shouldFilterOnlyUpInstances());