/** * Gets the unique ID for the next operator in the graph. The ID is of the following format: * jobName-jobId-opCode-(userDefinedId|nextOpNum); * * @param opCode the {@link OpCode} of the next operator * @param userDefinedId the optional user-provided name of the next operator or null * @return the unique ID for the next operator in the graph */ public String getNextOpId(OpCode opCode, String userDefinedId) { if (StringUtils.isNotBlank(userDefinedId) && !ID_PATTERN.matcher(userDefinedId).matches()) { throw new SamzaException("Operator ID must not contain spaces or special characters: " + userDefinedId); } JobConfig jobConfig = new JobConfig(getConfig()); String nextOpId = String.format("%s-%s-%s-%s", jobConfig.getName().get(), jobConfig.getJobId(), opCode.name().toLowerCase(), StringUtils.isNotBlank(userDefinedId) ? userDefinedId.trim() : String.valueOf(nextOpNum)); if (!operatorIds.add(nextOpId)) { throw new SamzaException( String.format("Found duplicate operator ID %s in the graph. Operator IDs must be unique.", nextOpId)); } nextOpNum++; return nextOpId; }
/** * Gets the unique ID for the next operator in the graph. The ID is of the following format: * jobName-jobId-opCode-(userDefinedId|nextOpNum); * * @param opCode the {@link OpCode} of the next operator * @param userDefinedId the optional user-provided name of the next operator or null * @return the unique ID for the next operator in the graph */ public String getNextOpId(OpCode opCode, String userDefinedId) { if (StringUtils.isNotBlank(userDefinedId) && !ID_PATTERN.matcher(userDefinedId).matches()) { throw new SamzaException("Operator ID must not contain spaces or special characters: " + userDefinedId); } JobConfig jobConfig = new JobConfig(getConfig()); String nextOpId = String.format("%s-%s-%s-%s", jobConfig.getName().get(), jobConfig.getJobId(), opCode.name().toLowerCase(), StringUtils.isNotBlank(userDefinedId) ? userDefinedId.trim() : String.valueOf(nextOpNum)); if (!operatorIds.add(nextOpId)) { throw new SamzaException( String.format("Found duplicate operator ID %s in the graph. Operator IDs must be unique.", nextOpId)); } nextOpNum++; return nextOpId; }
/** * Gets the unique ID for the next operator in the graph. The ID is of the following format: * jobName-jobId-opCode-(userDefinedId|nextOpNum); * * @param opCode the {@link OpCode} of the next operator * @param userDefinedId the optional user-provided name of the next operator or null * @return the unique ID for the next operator in the graph */ public String getNextOpId(OpCode opCode, String userDefinedId) { if (StringUtils.isNotBlank(userDefinedId) && !ID_PATTERN.matcher(userDefinedId).matches()) { throw new SamzaException("Operator ID must not contain spaces or special characters: " + userDefinedId); } JobConfig jobConfig = new JobConfig(getConfig()); String nextOpId = String.format("%s-%s-%s-%s", jobConfig.getName().get(), jobConfig.getJobId(), opCode.name().toLowerCase(), StringUtils.isNotBlank(userDefinedId) ? userDefinedId.trim() : String.valueOf(nextOpNum)); if (!operatorIds.add(nextOpId)) { throw new SamzaException( String.format("Found duplicate operator ID %s in the graph. Operator IDs must be unique.", nextOpId)); } nextOpNum++; return nextOpId; }
/** * Gets the unique ID for the next operator in the graph. The ID is of the following format: * jobName-jobId-opCode-(userDefinedId|nextOpNum); * * @param opCode the {@link OpCode} of the next operator * @param userDefinedId the optional user-provided name of the next operator or null * @return the unique ID for the next operator in the graph */ public String getNextOpId(OpCode opCode, String userDefinedId) { if (StringUtils.isNotBlank(userDefinedId) && !ID_PATTERN.matcher(userDefinedId).matches()) { throw new SamzaException("Operator ID must not contain spaces or special characters: " + userDefinedId); } JobConfig jobConfig = new JobConfig(getConfig()); String nextOpId = String.format("%s-%s-%s-%s", jobConfig.getName().get(), jobConfig.getJobId(), opCode.name().toLowerCase(), StringUtils.isNotBlank(userDefinedId) ? userDefinedId.trim() : String.valueOf(nextOpNum)); if (!operatorIds.add(nextOpId)) { throw new SamzaException( String.format("Found duplicate operator ID %s in the graph. Operator IDs must be unique.", nextOpId)); } nextOpNum++; return nextOpId; }
/** * Gets the unique ID for the next operator in the graph. The ID is of the following format: * jobName-jobId-opCode-(userDefinedId|nextOpNum); * * @param opCode the {@link OpCode} of the next operator * @param userDefinedId the optional user-provided name of the next operator or null * @return the unique ID for the next operator in the graph */ public String getNextOpId(OpCode opCode, String userDefinedId) { if (StringUtils.isNotBlank(userDefinedId) && !ID_PATTERN.matcher(userDefinedId).matches()) { throw new SamzaException("Operator ID must not contain spaces or special characters: " + userDefinedId); } JobConfig jobConfig = new JobConfig(getConfig()); String nextOpId = String.format("%s-%s-%s-%s", jobConfig.getName().get(), jobConfig.getJobId(), opCode.name().toLowerCase(), StringUtils.isNotBlank(userDefinedId) ? userDefinedId.trim() : String.valueOf(nextOpNum)); if (!operatorIds.add(nextOpId)) { throw new SamzaException( String.format("Found duplicate operator ID %s in the graph. Operator IDs must be unique.", nextOpId)); } nextOpNum++; return nextOpId; }
@Test public void testConstructor() { StreamApplication mockApp = mock(StreamApplication.class); Config mockConfig = getConfig(); StreamApplicationDescriptorImpl appDesc = new StreamApplicationDescriptorImpl(mockApp, mockConfig); verify(mockApp).describe(appDesc); assertEquals(mockConfig, appDesc.getConfig()); }