/** * Both Model and Set are oplog-only; they never pass the state on the wire, only the oplog; new * replicas are booted with distilled oplog as well. So, this is the only point in the code that * mutates the state of a Set. */ @SwarmOperation(kind = SwarmOperationKind.Logged) public void change(FullSpec spec, JsonValue value) throws SwarmException { value = this.distillOp(spec, value); if (!value.isObject()) return; JsonObject jo = (JsonObject) value; for (JsonObject.Member entry : jo) { String keySpecStr = entry.getName(); TypeIdSpec key_spec = new TypeIdSpec(keySpecStr); JsonValue val = entry.getValue(); if (TRUE.equals(val)) { T obj = this.host.get(key_spec); this.objects.put(key_spec, obj); obj.on(JsonValue.NULL, this.proxy); } else if (FALSE.equals(val)) { T obj = this.objects.get(key_spec); if (obj != null) { obj.off(this.proxy); this.objects.remove(key_spec); } } else { logger.warn("unexpected value: {}->{}", spec, value); } } }