@Test public void testUpdate() { long version = 5; Function.FunctionMetaData existingMetaData = Function.FunctionMetaData.newBuilder().setFunctionDetails( Function.FunctionDetails.newBuilder().setName("func-1").setParallelism(2)).setVersion(version).build(); Function.FunctionMetaData updatedMetaData = Function.FunctionMetaData.newBuilder().setFunctionDetails( Function.FunctionDetails.newBuilder().setName("func-1").setParallelism(3)).setVersion(version).build(); Function.FunctionMetaData newMetaData = FunctionMetaDataUtils.incrMetadataVersion(existingMetaData, updatedMetaData); Assert.assertEquals(newMetaData.getVersion(), version + 1); Assert.assertEquals(newMetaData.getFunctionDetails().getParallelism(), 3); newMetaData = FunctionMetaDataUtils.incrMetadataVersion(null, newMetaData); Assert.assertEquals(newMetaData.getVersion(), 0); }
public static Function.FunctionMetaData incrMetadataVersion(Function.FunctionMetaData existingMetaData, Function.FunctionMetaData updatedMetaData) { long version = 0; if (existingMetaData != null) { version = existingMetaData.getVersion() + 1; } return updatedMetaData.toBuilder() .setVersion(version) .build(); }
FunctionMetaDataUtils { public static Function.FunctionMetaData incrMetadataVersion(Function.FunctionMetaData existingMetaData, Function.FunctionMetaData updatedMetaData) { long version = 0; if (existingMetaData != null) { version = existingMetaData.getVersion() + 1; } return updatedMetaData.toBuilder() .setVersion(version) .build(); } }
FunctionMetaDataUtils { public static Function.FunctionMetaData incrMetadataVersion(Function.FunctionMetaData existingMetaData, Function.FunctionMetaData updatedMetaData) { long version = 0; if (existingMetaData != null) { version = existingMetaData.getVersion() + 1; } return updatedMetaData.toBuilder() .setVersion(version) .build(); }  }
FunctionMetaDataUtils { public static Function.FunctionMetaData incrMetadataVersion(Function.FunctionMetaData existingMetaData, Function.FunctionMetaData updatedMetaData) { long version = 0; if (existingMetaData != null) { version = existingMetaData.getVersion() + 1; } return updatedMetaData.toBuilder() .setVersion(version) .build(); }  static boolean canChangeState(Function.FunctionMetaData functionMetaData, int instanceId, Function.FunctionState newState); static Function.FunctionMetaData changeFunctionInstanceStatus(Function.FunctionMetaData functionMetaData,
                                                                         Integer instanceId, boolean start); static Function.FunctionMetaData incrMetadataVersion(Function.FunctionMetaData existingMetaData,
                                                                Function.FunctionMetaData updatedMetaData); }
FunctionMetaDataUtils { public static Function.FunctionMetaData incrMetadataVersion(Function.FunctionMetaData existingMetaData, Function.FunctionMetaData updatedMetaData) { long version = 0; if (existingMetaData != null) { version = existingMetaData.getVersion() + 1; } return updatedMetaData.toBuilder() .setVersion(version) .build(); }  static boolean canChangeState(Function.FunctionMetaData functionMetaData, int instanceId, Function.FunctionState newState); static Function.FunctionMetaData changeFunctionInstanceStatus(Function.FunctionMetaData functionMetaData,
                                                                         Integer instanceId, boolean start); static Function.FunctionMetaData incrMetadataVersion(Function.FunctionMetaData existingMetaData,
                                                                Function.FunctionMetaData updatedMetaData);  }