@Override public boolean execute() throws Exception { if (_controllerAddress == null) { if (_controllerHost == null) { _controllerHost = NetUtil.getHostAddress(); } _controllerAddress = "http://" + _controllerHost + ":" + _controllerPort; } if (!_exec) { LOGGER.warn("Dry Running Command: " + toString()); LOGGER.warn("Use the -exec option to actually execute the command."); return true; } LOGGER.info("Executing command: " + toString()); Tenant t = new Tenant.TenantBuilder(_name).setRole(_role).setTotalInstances(_instanceCount) .setOfflineInstances(_offlineInstanceCount).setRealtimeInstances(_realtimeInstanceCount).build(); String res = AbstractBaseAdminCommand .sendPostRequest(ControllerRequestURLBuilder.baseUrl(_controllerAddress).forTenantCreate(), t.toString()); LOGGER.info(res); System.out.print(res); return true; }
public static String buildServerTenantCreateRequestJSON(String tenantName, int numberOfInstances, int offlineInstances, int realtimeInstances) throws JsonProcessingException { Tenant tenant = new TenantBuilder(tenantName).setRole(TenantRole.SERVER).setTotalInstances(numberOfInstances) .setOfflineInstances(offlineInstances).setRealtimeInstances(realtimeInstances).build(); return JsonUtils.objectToString(tenant); } }
public static String buildBrokerTenantCreateRequestJSON(String tenantName, int numberOfInstances) throws JsonProcessingException { Tenant tenant = new TenantBuilder(tenantName).setRole(TenantRole.BROKER).setTotalInstances(numberOfInstances) .setOfflineInstances(0).setRealtimeInstances(0).build(); return JsonUtils.objectToString(tenant); }