GetClientPartitionAttributesCommand extends BaseCommand { @SuppressWarnings("unchecked") @Override public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection, final SecurityService securityService, long start) throws IOException, ClassNotFoundException, InterruptedException { String regionFullPath = null; regionFullPath = clientMessage.getPart(0).getCachedString(); String errMessage = ""; if (regionFullPath == null) { errMessage = "The input region path for the GetClientPartitionAttributes request is null"; logger.warn(errMessage); writeErrorResponse(clientMessage, MessageType.GET_CLIENT_PARTITION_ATTRIBUTES_ERROR, errMessage, serverConnection); serverConnection.setAsTrue(RESPONDED); return; } Region region = serverConnection.getCache().getRegion(regionFullPath); if (region == null) { logger.warn( "Region was not found during GetClientPartitionAttributes request for region path : {}", regionFullPath); errMessage = "Region was not found during GetClientPartitionAttributes request for region path : " + regionFullPath; writeErrorResponse(clientMessage, MessageType.GET_CLIENT_PARTITION_ATTRIBUTES_ERROR, errMessage.toString(), serverConnection); serverConnection.setAsTrue(RESPONDED); return; } try { Message responseMsg = serverConnection.getResponseMessage(); responseMsg.setTransactionId(clientMessage.getTransactionId()); responseMsg.setMessageType(MessageType.RESPONSE_CLIENT_PARTITION_ATTRIBUTES); PartitionedRegion prRgion = (PartitionedRegion) region; PartitionResolver partitionResolver = prRgion.getPartitionResolver(); int numParts = 2; if (partitionResolver != null) { numParts++; } responseMsg.setNumberOfParts(numParts); responseMsg.addObjPart(prRgion.getTotalNumberOfBuckets()); if (partitionResolver != null) { responseMsg.addObjPart(partitionResolver.getClass().toString().substring(6)); } String leaderRegionPath = null; PartitionedRegion leaderRegion = null; String leaderRegionName = prRgion.getColocatedWith(); if (leaderRegionName != null) { Cache cache = prRgion.getCache(); while (leaderRegionName != null) { leaderRegion = (PartitionedRegion) cache.getRegion(leaderRegionName); if (leaderRegion.getColocatedWith() == null) { leaderRegionPath = leaderRegion.getFullPath(); break; } else { leaderRegionName = leaderRegion.getColocatedWith(); } } } responseMsg.addObjPart(leaderRegionPath); responseMsg.send(); clientMessage.clearParts(); } catch (Exception e) { writeException(clientMessage, e, false, serverConnection); } finally { serverConnection.setAsTrue(Command.RESPONDED); } }  static Command getCommand(); @SuppressWarnings("unchecked") @Override void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
      final SecurityService securityService, long start);  }
@Test public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); this.getClientPartitionAttributesCommand.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.responseMessage).send(); }