GetClientPartitionAttributesCommand66 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) { logger.warn("The input region path for the GetClientPartitionAttributes request is null"); errMessage = "The input region path for the GetClientPartitionAttributes request is null"; writeErrorResponse(clientMessage, MessageType.GET_CLIENT_PARTITION_ATTRIBUTES_ERROR, errMessage.toString(), 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 : %s", 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); if (!(region instanceof PartitionedRegion)) { responseMsg.setNumberOfParts(2); responseMsg.addObjPart(-1); responseMsg.addObjPart(region.getFullPath()); } else { PartitionedRegion prRgion = (PartitionedRegion) region; PartitionResolver partitionResolver = prRgion.getPartitionResolver(); int numParts = 2; if (partitionResolver != null) { numParts++; } if (prRgion.isFixedPartitionedRegion()) { numParts++; } responseMsg.setNumberOfParts(numParts); responseMsg.addObjPart(prRgion.getTotalNumberOfBuckets()); 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); if (partitionResolver != null) { responseMsg.addObjPart(partitionResolver.getClass().toString().substring(6)); } if (prRgion.isFixedPartitionedRegion()) { Set<FixedPartitionAttributes> fpaSet = null; if (leaderRegion != null) { fpaSet = PartitionedRegionHelper.getAllFixedPartitionAttributes(leaderRegion); } else { fpaSet = PartitionedRegionHelper.getAllFixedPartitionAttributes(prRgion); } responseMsg.addObjPart(fpaSet); } } responseMsg.send(); clientMessage.clearParts(); } catch (Exception e) { writeException(clientMessage, e, false, serverConnection); } finally { serverConnection.setAsTrue(Command.RESPONDED); } } GetClientPartitionAttributesCommand66(); static Command getCommand(); @SuppressWarnings("unchecked") @Override void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
      final SecurityService securityService, long start);  }
@Test public void noSecuirtyShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); this.getClientPartitionAttributesCommand66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.responseMessage).send(); }