@Test public void testUpdateGroupDescription() { GroupBuckets buckets = new GroupBuckets(ImmutableList.of(failoverGroupBucket)); groupStore.deviceInitialAuditCompleted(deviceId1, true); groupStore.storeGroupDescription(groupDescription1); GroupKey newKey = new DefaultGroupKey("123".getBytes()); groupStore.updateGroupDescription(deviceId1, groupKey1, GroupStore.UpdateType.ADD, buckets, newKey); Group group1 = groupStore.getGroup(deviceId1, groupId1); assertThat(group1.appCookie(), is(newKey)); assertThat(group1.buckets().buckets(), hasSize(2)); }
@Override public void updateGroupDescription(DeviceId deviceId, GroupKey oldAppCookie, UpdateType type, GroupBuckets newBuckets, GroupKey newAppCookie) { if (mastershipService.getMasterFor(deviceId) != null && mastershipService.getLocalRole(deviceId) != MastershipRole.MASTER) { log.debug("updateGroupDescription: Device {} local role is not MASTER", deviceId); if (mastershipService.getMasterFor(deviceId) == null) { log.error("No Master for device {}..." + "Can not perform update group operation", deviceId); return; } GroupStoreMessage groupOp = GroupStoreMessage. createGroupUpdateRequestMsg(deviceId, oldAppCookie, type, newBuckets, newAppCookie); clusterCommunicator.unicast(groupOp, GroupStoreMessageSubjects.REMOTE_GROUP_OP_REQUEST, clusterMsgSerializer::serialize, mastershipService.getMasterFor(deviceId)).whenComplete((result, error) -> { if (error != null) { log.warn("Failed to send request to master: {} to {}", groupOp, mastershipService.getMasterFor(deviceId), error); } }); return; } log.debug("updateGroupDescription for device {} is getting handled locally", deviceId); updateGroupDescriptionInternal(deviceId, oldAppCookie, type, newBuckets, newAppCookie); }
DistributedGroupStore extends AbstractStore<GroupEvent, GroupStoreDelegate> implements GroupStore { @Override public void updateGroupDescription(DeviceId deviceId, GroupKey oldAppCookie, UpdateType type, GroupBuckets newBuckets, GroupKey newAppCookie) { if (mastershipService.getMasterFor(deviceId) != null && mastershipService.getLocalRole(deviceId) != MastershipRole.MASTER) { log.debug("updateGroupDescription: Device {} local role is not MASTER", deviceId); if (mastershipService.getMasterFor(deviceId) == null) { log.error("No Master for device {}..." + "Can not perform update group operation", deviceId); return; } GroupStoreMessage groupOp = GroupStoreMessage. createGroupUpdateRequestMsg(deviceId, oldAppCookie, type, newBuckets, newAppCookie); clusterCommunicator.unicast(groupOp, GroupStoreMessageSubjects.REMOTE_GROUP_OP_REQUEST, clusterMsgSerializer::serialize, mastershipService.getMasterFor(deviceId)).whenComplete((result, error) -> { if (error != null) { log.warn("Failed to send request to master: {} to {}", groupOp, mastershipService.getMasterFor(deviceId), error); } }); return; } log.debug("updateGroupDescription for device {} is getting handled locally", deviceId); updateGroupDescriptionInternal(deviceId, oldAppCookie, type, newBuckets, newAppCookie); } }
DistributedGroupStore extends AbstractStore<GroupEvent, GroupStoreDelegate> implements GroupStore { @Override public void updateGroupDescription(DeviceId deviceId, GroupKey oldAppCookie, UpdateType type, GroupBuckets newBuckets, GroupKey newAppCookie) { if (mastershipService.getMasterFor(deviceId) != null && mastershipService.getLocalRole(deviceId) != MastershipRole.MASTER) { log.debug("updateGroupDescription: Device {} local role is not MASTER", deviceId); if (mastershipService.getMasterFor(deviceId) == null) { log.error("No Master for device {}..." + "Can not perform update group operation", deviceId); return; } GroupStoreMessage groupOp = GroupStoreMessage. createGroupUpdateRequestMsg(deviceId, oldAppCookie, type, newBuckets, newAppCookie); clusterCommunicator.unicast(groupOp, GroupStoreMessageSubjects.REMOTE_GROUP_OP_REQUEST, clusterMsgSerializer::serialize, mastershipService.getMasterFor(deviceId)).whenComplete((result, error) -> { if (error != null) { log.warn("Failed to send request to master: {} to {}", groupOp, mastershipService.getMasterFor(deviceId), error); } }); return; } log.debug("updateGroupDescription for device {} is getting handled locally", deviceId); updateGroupDescriptionInternal(deviceId, oldAppCookie, type, newBuckets, newAppCookie); }  }
DistributedGroupStore extends AbstractStore<GroupEvent, GroupStoreDelegate> implements GroupStore { @Override public void updateGroupDescription(DeviceId deviceId, GroupKey oldAppCookie, UpdateType type, GroupBuckets newBuckets, GroupKey newAppCookie) { if (mastershipService.getMasterFor(deviceId) != null && mastershipService.getLocalRole(deviceId) != MastershipRole.MASTER) { log.debug("updateGroupDescription: Device {} local role is not MASTER", deviceId); if (mastershipService.getMasterFor(deviceId) == null) { log.error("No Master for device {}..." + "Can not perform update group operation", deviceId); return; } GroupStoreMessage groupOp = GroupStoreMessage. createGroupUpdateRequestMsg(deviceId, oldAppCookie, type, newBuckets, newAppCookie); clusterCommunicator.unicast(groupOp, GroupStoreMessageSubjects.REMOTE_GROUP_OP_REQUEST, clusterMsgSerializer::serialize, mastershipService.getMasterFor(deviceId)).whenComplete((result, error) -> { if (error != null) { log.warn("Failed to send request to master: {} to {}", groupOp, mastershipService.getMasterFor(deviceId), error); } }); return; } log.debug("updateGroupDescription for device {} is getting handled locally", deviceId); updateGroupDescriptionInternal(deviceId, oldAppCookie, type, newBuckets, newAppCookie); }  @Activate void activate(); @Deactivate void deactivate(); @Modified void modified(ComponentContext context); @Override int getGroupCount(DeviceId deviceId); @Override Iterable<Group> getGroups(DeviceId deviceId); @Override Group getGroup(DeviceId deviceId, GroupKey appCookie); @Override Group getGroup(DeviceId deviceId, GroupId groupId); @Override void storeGroupDescription(GroupDescription groupDesc); @Override void updateGroupDescription(DeviceId deviceId,
                                       GroupKey oldAppCookie,
                                       UpdateType type,
                                       GroupBuckets newBuckets,
                                       GroupKey newAppCookie); @Override void deleteGroupDescription(DeviceId deviceId,
                                       GroupKey appCookie); @Override void addOrUpdateGroupEntry(Group group); @Override void removeGroupEntry(Group group); @Override void purgeGroupEntry(DeviceId deviceId); @Override void deviceInitialAuditCompleted(DeviceId deviceId,
                                            boolean completed); @Override boolean deviceInitialAuditStatus(DeviceId deviceId); @Override void groupOperationFailed(DeviceId deviceId, GroupOperation operation); @Override void addOrUpdateExtraneousGroupEntry(Group group); @Override void removeExtraneousGroupEntry(Group group); @Override Iterable<Group> getExtraneousGroups(DeviceId deviceId); @Override void pushGroupMetrics(DeviceId deviceId,
                                 Collection<Group> groupEntries); }
DistributedGroupStore extends AbstractStore<GroupEvent, GroupStoreDelegate> implements GroupStore { @Override public void updateGroupDescription(DeviceId deviceId, GroupKey oldAppCookie, UpdateType type, GroupBuckets newBuckets, GroupKey newAppCookie) { if (mastershipService.getMasterFor(deviceId) != null && mastershipService.getLocalRole(deviceId) != MastershipRole.MASTER) { log.debug("updateGroupDescription: Device {} local role is not MASTER", deviceId); if (mastershipService.getMasterFor(deviceId) == null) { log.error("No Master for device {}..." + "Can not perform update group operation", deviceId); return; } GroupStoreMessage groupOp = GroupStoreMessage. createGroupUpdateRequestMsg(deviceId, oldAppCookie, type, newBuckets, newAppCookie); clusterCommunicator.unicast(groupOp, GroupStoreMessageSubjects.REMOTE_GROUP_OP_REQUEST, clusterMsgSerializer::serialize, mastershipService.getMasterFor(deviceId)).whenComplete((result, error) -> { if (error != null) { log.warn("Failed to send request to master: {} to {}", groupOp, mastershipService.getMasterFor(deviceId), error); } }); return; } log.debug("updateGroupDescription for device {} is getting handled locally", deviceId); updateGroupDescriptionInternal(deviceId, oldAppCookie, type, newBuckets, newAppCookie); }  @Activate void activate(); @Deactivate void deactivate(); @Modified void modified(ComponentContext context); @Override int getGroupCount(DeviceId deviceId); @Override Iterable<Group> getGroups(DeviceId deviceId); @Override Group getGroup(DeviceId deviceId, GroupKey appCookie); @Override Group getGroup(DeviceId deviceId, GroupId groupId); @Override void storeGroupDescription(GroupDescription groupDesc); @Override void updateGroupDescription(DeviceId deviceId,
                                       GroupKey oldAppCookie,
                                       UpdateType type,
                                       GroupBuckets newBuckets,
                                       GroupKey newAppCookie); @Override void deleteGroupDescription(DeviceId deviceId,
                                       GroupKey appCookie); @Override void addOrUpdateGroupEntry(Group group); @Override void removeGroupEntry(Group group); @Override void purgeGroupEntry(DeviceId deviceId); @Override void deviceInitialAuditCompleted(DeviceId deviceId,
                                            boolean completed); @Override boolean deviceInitialAuditStatus(DeviceId deviceId); @Override void groupOperationFailed(DeviceId deviceId, GroupOperation operation); @Override void addOrUpdateExtraneousGroupEntry(Group group); @Override void removeExtraneousGroupEntry(Group group); @Override Iterable<Group> getExtraneousGroups(DeviceId deviceId); @Override void pushGroupMetrics(DeviceId deviceId,
                                 Collection<Group> groupEntries);  }