code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
@Override public Map<String, ImageVersionMetadata> getVersionMetadataForAllImageTypes() throws ImageMgmtException { final Map<String, List<ImageRampup>> imageTypeRampups = this.imageRampupDao .getRampupForAllImageTypes(); final List<ImageType> imageTypeList = this.imageTypeDao.getAllImageTypes(); final Set<String> imageTypes = new TreeSet<>(); for (final ImageType imageType : imageTypeList) { imageTypes.add(imageType.getName()); } final Set<String> remainingImageTypes = new TreeSet<>(); final Map<String, ImageVersionMetadata> imageTypeVersionMap = this.processAndGetVersionForImageTypes(null, imageTypes, imageTypeRampups, remainingImageTypes); if (!remainingImageTypes.isEmpty()) { final Map<String, ImageVersion> imageTypeLatestNonActiveVersionMap = this.getLatestNonActiveImageVersion(remainingImageTypes); log.info("imageTypeLatestNonActiveVersionMap: " + imageTypeLatestNonActiveVersionMap); imageTypeLatestNonActiveVersionMap.forEach((k, v) -> imageTypeVersionMap.put(k, new ImageVersionMetadata(v, MSG_NON_ACTIVE_VERSION_SELECTION))); if (!remainingImageTypes.isEmpty()) { remainingImageTypes.forEach(k -> imageTypeVersionMap.put(k, new ImageVersionMetadata(null, MSG_IMAGE_TYPE_WITHOUT_VERSION))); } } return imageTypeVersionMap; }
This class is responsible for fetching the version of the available images based on currently active rampup plan and rampup details or the version which is already ramped up and active. Here is the version selection process for an image type - 1. Fetch the rampup details for the given image types or for all the image types (Two such methods are provided). 2. Sort the ramp up data in ascending order of rampup percentage. 3. Generate a random number between 1 to 100 both inclusive. Let us say the number the number generated is 60. 4. Let us say there are three versions 1.1.1, 1.1.2 & and 1.1.3 with rampup percantages 10, 30 and 60 respectively. 5. The above percentage fors three ranges [1 - 10], [11 - 40] & [41 - 100]. The random humber 60 belongs to the last range i.e. [41 - 100] and hence version 1.1.3 will be selected. If random number generated is 22 then version 1.1.2 will be selected and so on. 6. If there is no active rampup plan for an image type or in the active plan if the version is marked unstable or deprecated, and latest active version will be selected from the image_verions table. 7. If there is no active version in the image_versions table, it will throw appropriate error message mentioning could not select version for the image type and the whole process would fail. 8. Follow the rampup procedure to elect a new version from the image_versions table for the failed image type.
getVersionMetadataForAllImageTypes
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
@Override public Map<String, VersionInfo> validateAndGetUpdatedVersionMap( final ExecutableFlow executableFlow, final VersionSet versionSet) throws ImageMgmtException { // Find the image types for which version is either invalid or not exists final Set<String> imageTypesWithInvalidVersion = versionSet.getImageToVersionMap().entrySet() .stream() .filter(map -> this.imageVersionDao.isInvalidVersion( map.getKey(), map.getValue().getVersion())) .map(map -> map.getKey()) .collect(Collectors.toSet()); final Map<String, VersionInfo> updatedVersionInfoMap = new TreeMap<>( String.CASE_INSENSITIVE_ORDER); if (!imageTypesWithInvalidVersion.isEmpty()) { final Map<String, VersionInfo> versionInfoMap = this .getVersionByImageTypes(executableFlow, imageTypesWithInvalidVersion, new HashSet<>()); // Update the correct version in versionSet versionInfoMap.forEach((k, v) -> updatedVersionInfoMap.put(k, v)); versionSet.getImageToVersionMap().entrySet() .forEach(map -> updatedVersionInfoMap.putIfAbsent(map.getKey(), map.getValue())); } return updatedVersionInfoMap; }
This class is responsible for fetching the version of the available images based on currently active rampup plan and rampup details or the version which is already ramped up and active. Here is the version selection process for an image type - 1. Fetch the rampup details for the given image types or for all the image types (Two such methods are provided). 2. Sort the ramp up data in ascending order of rampup percentage. 3. Generate a random number between 1 to 100 both inclusive. Let us say the number the number generated is 60. 4. Let us say there are three versions 1.1.1, 1.1.2 & and 1.1.3 with rampup percantages 10, 30 and 60 respectively. 5. The above percentage fors three ranges [1 - 10], [11 - 40] & [41 - 100]. The random humber 60 belongs to the last range i.e. [41 - 100] and hence version 1.1.3 will be selected. If random number generated is 22 then version 1.1.2 will be selected and so on. 6. If there is no active rampup plan for an image type or in the active plan if the version is marked unstable or deprecated, and latest active version will be selected from the image_verions table. 7. If there is no active version in the image_versions table, it will throw appropriate error message mentioning could not select version for the image type and the whole process would fail. 8. Follow the rampup procedure to elect a new version from the image_versions table for the failed image type.
validateAndGetUpdatedVersionMap
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
@Override public Map<String, VersionInfo> getVersionByImageTypes(final ExecutableFlow flow, final Set<String> imageTypes, Set<String> overlayImageTypes) throws ImageMgmtException { final Map<String, List<ImageRampup>> imageTypeRampups = this.imageRampupDao .getRampupByImageTypes(imageTypes); final Set<String> remainingImageTypes = new TreeSet<>(); final Map<String, ImageVersionMetadata> imageTypeVersionMap = this.processAndGetVersionForImageTypes(flow, imageTypes, imageTypeRampups, remainingImageTypes); // Exclude images defined by flow parameter image.{image-type-name}.version remainingImageTypes.removeAll(overlayImageTypes); // Throw exception if there are left over image types if (!remainingImageTypes.isEmpty()) { throw new ImageMgmtException("Could not fetch version for below image types. Reasons: " + " 1. There is no active rampup plan in the image_rampup_plan table. 2. There is no " + " active version in the image_versions table. Image Types: " + remainingImageTypes); } return this.createVersionInfoMap(imageTypeVersionMap); }
This class is responsible for fetching the version of the available images based on currently active rampup plan and rampup details or the version which is already ramped up and active. Here is the version selection process for an image type - 1. Fetch the rampup details for the given image types or for all the image types (Two such methods are provided). 2. Sort the ramp up data in ascending order of rampup percentage. 3. Generate a random number between 1 to 100 both inclusive. Let us say the number the number generated is 60. 4. Let us say there are three versions 1.1.1, 1.1.2 & and 1.1.3 with rampup percantages 10, 30 and 60 respectively. 5. The above percentage fors three ranges [1 - 10], [11 - 40] & [41 - 100]. The random humber 60 belongs to the last range i.e. [41 - 100] and hence version 1.1.3 will be selected. If random number generated is 22 then version 1.1.2 will be selected and so on. 6. If there is no active rampup plan for an image type or in the active plan if the version is marked unstable or deprecated, and latest active version will be selected from the image_verions table. 7. If there is no active version in the image_versions table, it will throw appropriate error message mentioning could not select version for the image type and the whole process would fail. 8. Follow the rampup procedure to elect a new version from the image_versions table for the failed image type.
getVersionByImageTypes
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
@Override public VersionInfo getVersionInfo(final String imageType, final String imageVersion, final Set<State> stateFilter) throws ImageMgmtException { final Optional<ImageVersion> optionalImageVersion = this .fetchImageVersion(imageType, imageVersion); // If state filter is null or empty return the version info directly. // If state filter is present, apply the filter and return version info if (optionalImageVersion.isPresent() && ((stateFilter.isEmpty() || stateFilter == null) || stateFilter.contains(optionalImageVersion.get().getState()))) { return new VersionInfo(optionalImageVersion.get().getVersion(), optionalImageVersion.get().getPath(), optionalImageVersion.get().getState()); } else { if(stateFilter.isEmpty() || stateFilter == null) { throw new ImageMgmtException(String.format("Unable to get VersionInfo for image type: %s, " + "image version: %s", imageType, imageVersion)); } String states = stateFilter.stream().map(i -> i.toString()).collect(Collectors.joining(",")); throw new ImageMgmtException(String.format("Unable to get VersionInfo for image type: %s, " + "image version: %s that is in one of the following states: %s.", imageType, imageVersion, states)); } }
This class is responsible for fetching the version of the available images based on currently active rampup plan and rampup details or the version which is already ramped up and active. Here is the version selection process for an image type - 1. Fetch the rampup details for the given image types or for all the image types (Two such methods are provided). 2. Sort the ramp up data in ascending order of rampup percentage. 3. Generate a random number between 1 to 100 both inclusive. Let us say the number the number generated is 60. 4. Let us say there are three versions 1.1.1, 1.1.2 & and 1.1.3 with rampup percantages 10, 30 and 60 respectively. 5. The above percentage fors three ranges [1 - 10], [11 - 40] & [41 - 100]. The random humber 60 belongs to the last range i.e. [41 - 100] and hence version 1.1.3 will be selected. If random number generated is 22 then version 1.1.2 will be selected and so on. 6. If there is no active rampup plan for an image type or in the active plan if the version is marked unstable or deprecated, and latest active version will be selected from the image_verions table. 7. If there is no active version in the image_versions table, it will throw appropriate error message mentioning could not select version for the image type and the whole process would fail. 8. Follow the rampup procedure to elect a new version from the image_versions table for the failed image type.
getVersionInfo
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
private Map<String, ImageVersionMetadata> processAndGetVersionForImageTypes( final ExecutableFlow flow, final Set<String> imageTypes, final Map<String, List<ImageRampup>> imageTypeRampups, final Set<String> remainingImageTypes) { final Set<String> rampupImageTypeSet = imageTypeRampups.keySet(); log.info("Found active rampup for the image types {} ", rampupImageTypeSet); final Map<String, ImageVersionMetadata> imageTypeVersionMap = new TreeMap<>( String.CASE_INSENSITIVE_ORDER); // select current flow's image versions based on ramp up plan and ramp rule(exclusive list) final Map<String, ImageVersion> imageTypeRampupVersionMap = this.processAndGetRampupVersion(flow, imageTypeRampups); imageTypeRampupVersionMap .forEach((k, v) -> imageTypeVersionMap.put(k, new ImageVersionMetadata(v, imageTypeRampups.get(k), MSG_RANDOM_RAMPUP_VERSION_SELECTION))); log.info("After processing rampup records -> imageTypeVersionMap: {}", imageTypeVersionMap); /* * Fetching the latest active image version from image_versions table for the remaining image * types for which there is no active rampup plan or the versions are marked as * unstable/deprecated in the active plan. */ // Converts the input image types to lowercase for case insensitive comparison. final Set<String> imageTypesInLowerCase = imageTypes.stream().map(String::toLowerCase).collect(Collectors.toSet()); remainingImageTypes.addAll(imageTypesInLowerCase); remainingImageTypes .removeAll(imageTypeVersionMap.keySet().stream().map(String::toLowerCase).collect( Collectors.toSet())); log.info("After finding version through rampup image types remaining: {} ", remainingImageTypes); final Map<String, ImageVersion> imageTypeActiveVersionMap = this.processAndGetActiveImageVersion(remainingImageTypes); imageTypeActiveVersionMap .forEach((k, v) -> imageTypeVersionMap.put(k, new ImageVersionMetadata(v, MSG_ACTIVE_VERSION_SELECTION))); log.info("After fetching active image version -> imageTypeVersionMap {}", imageTypeVersionMap); // For the leftover image types throw exception with appropriate error message. remainingImageTypes .removeAll(imageTypeVersionMap.keySet().stream().map(String::toLowerCase).collect( Collectors.toSet())); log.info("After fetching version using ramp up and based on active image version the " + "image types remaining: {} ", remainingImageTypes); return imageTypeVersionMap; }
This method processes image type rampup details for the image type and selects a version for the image type. Here is the version selection process for an image type 1. Sort the ramp up data in the ascending order of rampup percentage. 2. Generate a random number between 1 to 100 both inclusive. Let us say the number the number generated is 60. 3. Let us say there are three versions 1.1.1, 1.1.2 & and 1.1.3 with rampup percantages 10, 30 & 60 respectively. 4. The above percentage fors three ranges [1 - 10], [11 - 40] & [41 - 100]. The random humber 60 belongs to the last range i.e. [41 - 100] and hence version 1.1.3 will be selected. If random number generated is 22 then version 1.1.2 will be selected and so on. 5. If there is no active rampup plan for an image type or in the active plan if the version is marked unstable or deprecated, and latest active version will be selected from the image_verions table. 6. If there is no active version in the image_versions table, it will throw appropriate error message mentioning could not select version for the image type and the whole process would fail. 7. Follow the rampup procedure to elect a new version from the image_versions table for the ailed image type. @param imageTypes - set of specified image types @param imageTypeRampups - contains rampup list for an image type @param remainingImageTypes - This set is used to keep track of the image types for which version metadata is not available. @return Map<String, VersionMetadata>
processAndGetVersionForImageTypes
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
private Map<String, ImageVersion> processAndGetRampupVersion( final ExecutableFlow flow, final Map<String, List<ImageRampup>> imageTypeRampups) { final Set<String> rampupImageTypeSet = imageTypeRampups.keySet(); log.info("Found active rampup for the image types {} ", rampupImageTypeSet); final Map<String, ImageVersion> imageTypeRampupVersionMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); if (rampupImageTypeSet.isEmpty()) { log.warn("No active rampup found for the image types"); return imageTypeRampupVersionMap; } log.info("Found active rampup for the image types {} ", rampupImageTypeSet); for (final String imageTypeName : rampupImageTypeSet) { final List<ImageRampup> imageRampupList = imageTypeRampups.get(imageTypeName); if (imageRampupList.isEmpty()) { log.info("ImageRampupList was empty, so continue"); continue; } if (null == flow) { log.info("Flow object is null, so continue"); final ImageRampup firstImageRampup = imageRampupList.get(0); imageTypeRampupVersionMap.put(imageTypeName, this.fetchImageVersion(imageTypeName, firstImageRampup.getImageVersion()) .orElseThrow(() -> new ImageMgmtException( String.format("Unable to fetch version %s from image " + "versions table.", firstImageRampup.getImageVersion())))); } else { int prevRampupPercentage = 0; final int flowNameHashValMapping = ContainerImplUtils.getFlowNameHashValMapping(flow); log.info("HashValMapping: " + flowNameHashValMapping); for (final ImageRampup imageRampup : imageRampupList) { final int rampupPercentage = imageRampup.getRampupPercentage(); if (flowNameHashValMapping >= prevRampupPercentage + 1 && flowNameHashValMapping <= prevRampupPercentage + rampupPercentage) { // when flow is excluded by a ramp rule, will use default active version for that image type if (imageRampRuleDao.isExcludedByRampRule( flow.getFlowName(), imageTypeName, imageRampup.getImageVersion())) { imageTypeRampupVersionMap.put(imageTypeName, fetchActiveImageVersion(imageTypeName) .orElseThrow(() -> new ImageMgmtDaoException( "fail to find active image version for {}" + imageTypeName))); log.debug("The image version {} is deselected for image type {} with rampup percentage {} " + "and use active current one", imageRampup.getImageVersion(), imageTypeName, rampupPercentage); } else { imageTypeRampupVersionMap.put(imageTypeName, this.fetchImageVersion(imageTypeName, imageRampup.getImageVersion()) .orElseThrow(() -> new ImageMgmtException( String.format("Unable to fetch version %s from image " + "versions table.", imageRampup.getImageVersion())))); log.debug("The image version {} is selected for image type {} with rampup percentage {}", imageRampup.getImageVersion(), imageTypeName, rampupPercentage); } break; } log.info("ImageTypeRampupVersionMap: " + imageTypeRampupVersionMap); prevRampupPercentage += rampupPercentage; } } } return imageTypeRampupVersionMap; }
Method to process the rampup list and get the rampup version based on rampup logic for the given image types in the rampup map. If there is a ramp rule defined for this ramp up plan, the image version would be deselected and use the current active version instead. @param imageTypeRampups @return Map<String, ImageVersion>
processAndGetRampupVersion
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
private Map<String, ImageVersion> processAndGetActiveImageVersion(final Set<String> imageTypes) { final Map<String, ImageVersion> imageTypeActiveVersionMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); if (!CollectionUtils.isEmpty(imageTypes)) { final List<ImageVersion> imageVersions = this.imageVersionDao.getActiveVersionByImageTypes(imageTypes); log.debug("Active image versions fetched: {} ", imageVersions); if (imageVersions != null && !imageVersions.isEmpty()) { for (final ImageVersion imageVersion : imageVersions) { imageTypeActiveVersionMap.put(imageVersion.getName(), imageVersion); } } } return imageTypeActiveVersionMap; }
Process and get latest active image version for the given image types. @param imageTypes @return Map<String, ImageVersion>
processAndGetActiveImageVersion
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
private Map<String, ImageVersion> getLatestNonActiveImageVersion(final Set<String> imageTypes) { final Map<String, ImageVersion> imageTypeLatestNonActiveVersionMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); if (!CollectionUtils.isEmpty(imageTypes)) { final List<ImageVersion> imageVersions = this.imageVersionDao.getLatestNonActiveVersionByImageTypes(imageTypes); log.info("Non Active image versions fetched: {} ", imageVersions); if (imageVersions != null && !imageVersions.isEmpty()) { for (final ImageVersion imageVersion : imageVersions) { imageTypeLatestNonActiveVersionMap.put(imageVersion.getName(), imageVersion); } // Retain the the remaining/left over image types (i.e. image types without any version) imageTypes.removeAll(imageTypeLatestNonActiveVersionMap.keySet().stream() .map(String::toLowerCase) .collect(Collectors.toSet())); } } return imageTypeLatestNonActiveVersionMap; }
Get latest non active image version for the given image types. @param imageTypes @return Map<String, ImageVersion>
getLatestNonActiveImageVersion
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
private Optional<ImageVersion> fetchImageVersion(final String imageType, final String imageVersion) { final ImageMetadataRequest imageMetadataRequest = ImageMetadataRequest.newBuilder() .addParam(ImageMgmtConstants.IMAGE_TYPE, imageType) .addParam(ImageMgmtConstants.IMAGE_VERSION, imageVersion) .build(); final List<ImageVersion> imageVersions = this.imageVersionDao .findImageVersions(imageMetadataRequest); if (CollectionUtils.isEmpty(imageVersions)) { return Optional.empty(); } // Return only the imageVersion only when the image type/name matches for (final ImageVersion version : imageVersions) { if (version.getName().equalsIgnoreCase(imageType) && version.getVersion() .equalsIgnoreCase(imageVersion)) { return Optional.of(version); } } return Optional.empty(); }
Method to fetch image version based on image type and image version. @param imageType @param imageVersion @return Optional<ImageVersion>
fetchImageVersion
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
private Optional<ImageVersion> fetchActiveImageVersion(String imageType) { Set<String> imageTypeSet = new HashSet<>(); imageTypeSet.add(imageType); List<ImageVersion> imageVersions = imageVersionDao.getActiveVersionByImageTypes(imageTypeSet); if (imageVersions.isEmpty()) { log.debug("found no active image version for {}", imageType); return Optional.empty(); } else { log.debug("fetch active image version {} for {}", imageVersions.get(0).getVersion(), imageType); return Optional.of(imageVersions.get(0)); } }
Method to fetch active image version based on given image type. @param imageType @return Optional<ImageVersion>
fetchActiveImageVersion
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
private Map<String, VersionInfo> createVersionInfoMap( final Map<String, ImageVersionMetadata> imageVersionMetadataMap) { final Map<String, VersionInfo> versionInfoMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); imageVersionMetadataMap.forEach((k, v) -> versionInfoMap.put(k, new VersionInfo(v.getImageVersion().getVersion(), v.getImageVersion().getPath(), v.getImageVersion().getState()))); return versionInfoMap; }
Creates VersionInfo map from the ImageVersionMetadata map for the given image type keys. @param imageVersionMetadataMap @return Map<String, VersionInfo>
createVersionInfoMap
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
private Comparator<ImageRampup> getRampupPercentageComparator() { return Comparator.comparingInt(ImageRampup::getRampupPercentage); }
Return rampup percentage comparator @return Comparator<ImageRampup>
getRampupPercentageComparator
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/rampup/ImageRampupManagerImpl.java
Apache-2.0
@Override public KeyDeserializer findKeyDeserializer(final JavaType type, final DeserializationConfig config, final BeanDescription beanDesc, final BeanProperty property) throws JsonMappingException { if ((type.getRawClass() != String.class) && (type.getRawClass() != Object.class)) { throw new IllegalArgumentException( "expected String or Object, found " + type.getRawClass().getName()); } return DESERIALIZER; }
This method is invoked while deserializing JSON content field names to Map keys. In this case, only keys of type string or object is considered. @param type @param config @param beanDesc @param property @return KeyDeserializer @throws JsonMappingException
findKeyDeserializer
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/utils/CaseInsensitiveKeyDeserializers.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/utils/CaseInsensitiveKeyDeserializers.java
Apache-2.0
@Override public Object deserializeKey(final String key, final DeserializationContext ctxt) throws IOException { return key.toLowerCase(); }
This method deserializes a given key to lowercase. @param key @param ctxt @return Object @throws IOException
deserializeKey
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/utils/CaseInsensitiveKeyDeserializers.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/utils/CaseInsensitiveKeyDeserializers.java
Apache-2.0
public <T extends BaseDTO> T convertToDTO(final String jsonPayloadString, final Class<T> dtoClass) throws ImageMgmtInvalidInputException { try { return this.objectMapper.readValue(jsonPayloadString, dtoClass); } catch (final JsonParseException e) { log.error("Exception while parsing input json ", e); throw new ImageMgmtInvalidInputException(ErrorCode.BAD_REQUEST, "Exception while reading input payload. Invalid input."); } catch (final JsonMappingException e) { log.error("Exception while converting input json ", e); throw new ImageMgmtInvalidInputException(ErrorCode.BAD_REQUEST, "Exception while reading input payload. Invalid input."); } catch (final IOException e) { log.error("IOException occurred while converting input json ", e); throw new ImageMgmtInvalidInputException(ErrorCode.BAD_REQUEST, "Exception while reading input payload. Invalid input."); } }
Converts Json input payload to API specific model (DTO). @param jsonPayloadString @param dtoClass @param <T> @return DTO @throws ImageMgmtInvalidInputException
convertToDTO
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/utils/ConverterUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/utils/ConverterUtils.java
Apache-2.0
public <T extends BaseDTO> List<T> convertToDTOs(final String jsonPayloadString, final Class<T> dtoClass) throws ImageMgmtInvalidInputException { try { final TypeFactory typeFactory = this.objectMapper.getTypeFactory(); final JavaType javaType = typeFactory.constructParametricType(ArrayList.class, dtoClass); return this.objectMapper.readValue(jsonPayloadString, javaType); } catch (final JsonParseException e) { log.error("Exception while parsing input json ", e); throw new ImageMgmtInvalidInputException( "Exception while reading input payload. Invalid input."); } catch (final JsonMappingException e) { log.error("Exception while converting input json ", e); throw new ImageMgmtInvalidInputException( "Exception while reading input payload. Invalid input."); } catch (final IOException e) { log.error("IOException occurred while converting input json ", e); throw new ImageMgmtInvalidInputException( "Exception while reading input payload. Invalid input."); } }
Converts input json payload to API speific models (DTOs). @param jsonPayloadString @param <T> @return List<T> @throws ImageMgmtInvalidInputException
convertToDTOs
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/utils/ConverterUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/utils/ConverterUtils.java
Apache-2.0
@Override public synchronized Optional<VersionSet> insertAndGetVersionSet(final String versionSetMd5Hex, final String versionSetJsonString) throws ImageMgmtException { final SQLTransaction<Integer> insertVersionSet = transOperator -> { final VersionSetHandler versionSetHandler = new VersionSetHandler(); // Check if the versionSet already exists for versionSetMd5Hex final List<VersionSet> versionSets = transOperator .query(SELECT_VSET_FROM_MD5, versionSetHandler, versionSetMd5Hex); if (versionSets.size() > 1) { throw new SQLException( "Expected only one VersionSet for versionSetMd5Hex " + versionSetMd5Hex); } // Insert if it doesn't if (versionSets.isEmpty()) { transOperator.update(INSERT_VSET, versionSetMd5Hex, versionSetJsonString); return (int) transOperator.getLastInsertId(); } return versionSets.get(0).getVersionSetId(); }; try { final Integer versionSetId = this.dbOperator.transaction(insertVersionSet); final VersionSet versionSet = new VersionSet(versionSetJsonString, versionSetMd5Hex, versionSetId); this.md5ToVersionSet.put(versionSetMd5Hex, versionSet); this.idToVersionSet.put(versionSetId, versionSet); return Optional.of(versionSet); } catch (final SQLException e) { logger.error("Exception occurred while inserting version set and getting version id", e); throw new ImageMgmtException("Unable to insert and get versionSetId", e); } }
This method inserts the versionSetJsonString and versionSetMd5Hex to the Table version_set and get the versionSetId autogenerated post insertion.
insertAndGetVersionSet
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
Apache-2.0
@Override public synchronized boolean deleteVersionSet(final String versionSetMd5Hex) throws ImageMgmtException { final SQLTransaction<Integer> insertVersionSet = transOperator -> transOperator .update(DELETE_VSET, versionSetMd5Hex); try { final Integer rowsDeleted = this.dbOperator.transaction(insertVersionSet); if (this.md5ToVersionSet.containsKey(versionSetMd5Hex)) { final VersionSet removedVersionSet = this.md5ToVersionSet.remove(versionSetMd5Hex); this.idToVersionSet.remove(removedVersionSet.getVersionSetId()); } return rowsDeleted != 0; } catch (final SQLException e) { logger.error("Failed to execute: " + DELETE_VSET, e); throw new ImageMgmtException( "Exception occurred while removing version set for " + versionSetMd5Hex, e); } }
Deletes the versionSet row from the table version_set corresponding to versionSetMd5Hex.
deleteVersionSet
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
Apache-2.0
@Override public synchronized Optional<VersionSet> getVersionSet(final String versionSetMd5Hex, final String versionSetJsonString) throws ImageMgmtException { if (this.md5ToVersionSet.containsKey(versionSetMd5Hex)) { final VersionSet versionSet = this.md5ToVersionSet.get(versionSetMd5Hex); return Optional.of(versionSet); } return insertAndGetVersionSet(versionSetMd5Hex, versionSetJsonString); }
This method first checks if the versionSetId already exists in the local copy of the versionSets, otherwise, it will insert the versionSet into the table and get the resulting versionSetId.
getVersionSet
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
Apache-2.0
@Override public synchronized Optional<VersionSet> getVersionSet(final String versionSetMd5Hex) throws ImageMgmtException { if (this.md5ToVersionSet.containsKey(versionSetMd5Hex)) { return Optional.of(this.md5ToVersionSet.get(versionSetMd5Hex)); } final VersionSetHandler versionSetHandler = new VersionSetHandler(); try { final List<VersionSet> versionSets = this.dbOperator .query(SELECT_VSET_FROM_MD5, versionSetHandler, versionSetMd5Hex); if (versionSets.size() > 1) { throw new ImageMgmtException( "Expected only one VersionSet for versionSetMd5Hex " + versionSetMd5Hex); } if (versionSets.isEmpty()) { logger.info("No VersionSet exists for versionSetMd5Hex " + versionSetMd5Hex); return Optional.empty(); } final VersionSet versionSet = versionSets.get(0); this.idToVersionSet.put(versionSet.getVersionSetId(), versionSet); this.md5ToVersionSet.put(versionSetMd5Hex, versionSet); return Optional.of(versionSet); } catch (final SQLException e) { logger.error("Failed to execute: " + SELECT_VSET_FROM_MD5, e); throw new ImageMgmtException( "Failed to fetch VersionSet for versionSetMd5Hex " + versionSetMd5Hex, e); } }
This method first check if the versionSet exists in the local copy of versionSets, otherwise, it gets the copy from the version_set table and updates the local copy.
getVersionSet
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
Apache-2.0
@Override public synchronized Optional<VersionSet> getVersionSetById(final int versionSetId) throws ImageMgmtException { if (this.idToVersionSet.containsKey(versionSetId)) { return Optional.of(this.idToVersionSet.get(versionSetId)); } final VersionSetHandler versionSetHandler = new VersionSetHandler(); try { final List<VersionSet> versionSets = this.dbOperator .query(SELECT_VSET_FROM_ID, versionSetHandler, versionSetId); if (versionSets.size() > 1) { throw new ImageMgmtException( "Expected only one VersionSet for versionSetId " + versionSetId); } if (versionSets.isEmpty()) { logger.info("No VersionSet exists for versionSetId " + versionSetId); return Optional.empty(); } final VersionSet versionSet = versionSets.get(0); this.idToVersionSet.put(versionSetId, versionSet); this.md5ToVersionSet.put(versionSet.getVersionSetMd5Hex(), versionSet); return Optional.of(versionSet); } catch (final SQLException e) { logger.error("Failed to execute: " + SELECT_VSET_FROM_ID, e); throw new ImageMgmtException("Failed to fetch VersionSet for versionSetId " + versionSetId, e); } }
This method first check if the versionSet exists in the local copy of versionSets, otherwise, it gets the copy from the version_set table and updates the local copy.
getVersionSetById
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
Apache-2.0
@Override public synchronized List<VersionSet> fetchAllVersionSets() throws ImageMgmtException { final VersionSetHandler versionSetHandler = new VersionSetHandler(); try { return this.dbOperator.query(SELECT_ALL_VSET, versionSetHandler); } catch (final SQLException e) { logger.error("Failed to execute: " + SELECT_ALL_VSET, e); throw new ImageMgmtException("Failed to fetch all VersionSets ", e); } }
Fetches all the rows from the version_set table and returns it as List of VersionSet.
fetchAllVersionSets
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
Apache-2.0
@Override public List<VersionSet> handle(final ResultSet rs) throws SQLException { final List<VersionSet> versionSets = new ArrayList<>(); while (rs.next()) { final int versionSetId = rs.getInt(VERSIONSET_ID_IDX); final String versionSetMd5Hex = rs.getString(VERSIONSET_MD5_IDX); final String versionSetJsonString = rs.getString(VERSIONSET_JSON_IDX); try { versionSets.add(new VersionSet(versionSetJsonString, versionSetMd5Hex, versionSetId)); } catch (final Exception e) { throw new SQLException(e); } } return versionSets; }
A Handler class to modify the result set into List of VersionSet.
handle
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/JdbcVersionSetLoader.java
Apache-2.0
public String getVersion() { return this.version; }
This class represents image version specific info such as version, path and current state. This POJO class is stored as a version information for the given image type in VersionSet.
getVersion
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
Apache-2.0
public String getPath() { return this.path; }
This class represents image version specific info such as version, path and current state. This POJO class is stored as a version information for the given image type in VersionSet.
getPath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
Apache-2.0
public State getState() { return state; }
This class represents image version specific info such as version, path and current state. This POJO class is stored as a version information for the given image type in VersionSet.
getState
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
Apache-2.0
public String pathWithVersion() { Preconditions.checkNotNull(path, "path should not be null"); Preconditions.checkNotNull(version, "version should not be null"); return String.join(":", path, version); }
This class represents image version specific info such as version, path and current state. This POJO class is stored as a version information for the given image type in VersionSet.
pathWithVersion
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
Apache-2.0
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } VersionInfo that = (VersionInfo) o; return Objects.equals(version, that.version) && Objects.equals(path, that.path) && state == that.state; }
This class represents image version specific info such as version, path and current state. This POJO class is stored as a version information for the given image type in VersionSet.
equals
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
Apache-2.0
@Override public int hashCode() { return Objects.hash(version, path, state); }
This class represents image version specific info such as version, path and current state. This POJO class is stored as a version information for the given image type in VersionSet.
hashCode
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionInfo.java
Apache-2.0
public VersionSetBuilder addElement(final String key, final VersionInfo versionInfo) { this.versionSetElements.put(key, versionInfo); return this; }
This builder class is responsible for creating key-ordered json string for the version set, to ensure that the same execution environment will have the same string and hence the md5 digest will remain the same.
addElement
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionSetBuilder.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionSetBuilder.java
Apache-2.0
public VersionSetBuilder addElements(final Map<String, VersionInfo> keyVals) { this.versionSetElements.putAll(keyVals); return this; }
This builder class is responsible for creating key-ordered json string for the version set, to ensure that the same execution environment will have the same string and hence the md5 digest will remain the same.
addElements
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionSetBuilder.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionSetBuilder.java
Apache-2.0
public VersionSet build() throws IOException { final ObjectMapper objectMapper = new ObjectMapper(); final String versionSetJsonString = objectMapper.writeValueAsString(this.versionSetElements); final String versionSetMd5Hex = DigestUtils.md5Hex(versionSetJsonString); return this.loader.getVersionSet(versionSetMd5Hex, versionSetJsonString) .orElse(null); // null implies Exception was thrown by the Dao Layer }
This builder class is responsible for creating key-ordered json string for the version set, to ensure that the same execution environment will have the same string and hence the md5 digest will remain the same.
build
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionSetBuilder.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/imagemgmt/version/VersionSetBuilder.java
Apache-2.0
@Override public int getNumRunningFlows() { return this.containerizedDispatchManager.getRunningFlowIds().size(); }
JMX for Containerized execution manager to monitor executions which are dispatched on containers.
getNumRunningFlows
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
Apache-2.0
@Override public String getRunningFlows() { return this.containerizedDispatchManager.getRunningFlowIds().toString(); }
JMX for Containerized execution manager to monitor executions which are dispatched on containers.
getRunningFlows
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
Apache-2.0
@Override public boolean isQueueProcessorActive() { return this.containerizedDispatchManager.isQueueProcessorThreadActive(); }
JMX for Containerized execution manager to monitor executions which are dispatched on containers.
isQueueProcessorActive
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
Apache-2.0
@Override public String getQueuedFlows() { return this.containerizedDispatchManager.getQueuedFlowIds().toString(); }
JMX for Containerized execution manager to monitor executions which are dispatched on containers.
getQueuedFlows
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
Apache-2.0
@Override public String getQueueProcessorThreadState() { return this.containerizedDispatchManager.getQueueProcessorThreadState().toString(); }
JMX for Containerized execution manager to monitor executions which are dispatched on containers.
getQueueProcessorThreadState
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxContainerizedDispatchManager.java
Apache-2.0
@Override public int getNumRunningFlows() { return this.controller.getRunningFlowIds().size(); }
JMX for execution controller to monitor executions.
getNumRunningFlows
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxExecutionController.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxExecutionController.java
Apache-2.0
@Override public List<String> getPrimaryExecutorHostPorts() { return new ArrayList<>(this.controller.getPrimaryServerHosts()); }
JMX for execution controller to monitor executions.
getPrimaryExecutorHostPorts
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxExecutionController.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxExecutionController.java
Apache-2.0
@Override public String getRunningFlows() { return this.controller.getRunningFlowIds().toString(); }
JMX for execution controller to monitor executions.
getRunningFlows
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxExecutionController.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxExecutionController.java
Apache-2.0
@Override public String getQueuedFlows() { return this.controller.getQueuedFlowIds().toString(); }
JMX for execution controller to monitor executions.
getQueuedFlows
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxExecutionController.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxExecutionController.java
Apache-2.0
public static JmxJobMBeanManager getInstance() { return INSTANCE; }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
getInstance
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
public void initialize(final Props props) { logger.info("Initializing " + getClass().getName()); this.initialized = true; }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
initialize
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
@Override public int getNumRunningJobs() { return this.runningJobCount.get(); }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
getNumRunningJobs
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
@Override public int getTotalNumExecutedJobs() { return this.totalExecutedJobCount.get(); }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
getTotalNumExecutedJobs
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
@Override public int getTotalFailedJobs() { return this.totalFailedJobCount.get(); }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
getTotalFailedJobs
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
@Override public int getTotalSucceededJobs() { return this.totalSucceededJobCount.get(); }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
getTotalSucceededJobs
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
@Override public Map<String, Integer> getTotalSucceededJobsByJobType() { return convertMapValueToInteger(this.jobTypeSucceededMap); }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
getTotalSucceededJobsByJobType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
@Override public Map<String, Integer> getTotalFailedJobsByJobType() { return convertMapValueToInteger(this.jobTypeFailureMap); }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
getTotalFailedJobsByJobType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
private Map<String, Integer> convertMapValueToInteger( final Map<String, AtomicInteger> map) { final Map<String, Integer> result = new HashMap<>(map.size()); for (final Map.Entry<String, AtomicInteger> entry : map.entrySet()) { result.put(entry.getKey(), entry.getValue().intValue()); } return result; }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
convertMapValueToInteger
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
@Override public void handleEvent(final Event event) { if (!this.initialized) { throw new RuntimeException("JmxJobMBeanManager has not been initialized"); } if (event.getRunner() instanceof JobRunnerBase) { final EventData eventData = event.getData(); if (logger.isDebugEnabled()) { logger.debug("*** got " + event.getType() + " " + eventData.getJobId() + " " + event.getRunner().getClass().getName() + " status: " + eventData.getStatus()); } if (event.getType() == EventType.JOB_STARTED) { this.runningJobCount.incrementAndGet(); } else if (event.getType() == EventType.JOB_FINISHED) { this.totalExecutedJobCount.incrementAndGet(); if (this.runningJobCount.intValue() > 0) { this.runningJobCount.decrementAndGet(); } else { logger.warn("runningJobCount not messed up, it is already zero " + "and we are trying to decrement on job event " + EventType.JOB_FINISHED); } if (eventData.getStatus() == Status.FAILED) { this.totalFailedJobCount.incrementAndGet(); } else if (eventData.getStatus() == Status.SUCCEEDED) { this.totalSucceededJobCount.incrementAndGet(); } handleJobFinishedCount(eventData.getStatus(), eventData.getNodeType()); } } else { logger.warn("((((((((( Got a different runner: " + event.getRunner().getClass().getName()); } }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
handleEvent
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
private void handleJobFinishedCount(final Status status, final String jobType) { switch (status) { case FAILED: handleJobFinishedByType(this.jobTypeFailureMap, jobType); break; case SUCCEEDED: handleJobFinishedByType(this.jobTypeSucceededMap, jobType); break; default: } }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
handleJobFinishedCount
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
private void handleJobFinishedByType(final Map<String, AtomicInteger> jobTypeMap, final String jobType) { synchronized (jobTypeMap) { AtomicInteger count = jobTypeMap.get(jobType); if (count == null) { count = new AtomicInteger(); } count.incrementAndGet(); jobTypeMap.put(jobType, count); } }
Responsible keeping track of job related MBean attributes through listening to job related events. @author hluu
handleJobFinishedByType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jmx/JmxJobMBeanManager.java
Apache-2.0
public static void initialize(final Props props) { if (isInitialized) { logger.info("Already initialized"); return; } logger.info("Initializing"); instance = new JobCallbackManager(props); isInitialized = true; }
Responsible processing job callback properties on job status change events. When job callback properties are specified, they will be converted to HTTP calls to execute. The HTTP requests will be made in asynchronous mode so the caller to the handleEvent method will not be block. In addition, the HTTP calls will be configured to time appropriately for connection request, creating connection, and socket timeout. The HTTP request and response will be logged out the job's log for debugging and traceability purpose. @author hluu
initialize
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
Apache-2.0
public static boolean isInitialized() { return isInitialized; }
Responsible processing job callback properties on job status change events. When job callback properties are specified, they will be converted to HTTP calls to execute. The HTTP requests will be made in asynchronous mode so the caller to the handleEvent method will not be block. In addition, the HTTP calls will be configured to time appropriately for connection request, creating connection, and socket timeout. The HTTP request and response will be logged out the job's log for debugging and traceability purpose. @author hluu
isInitialized
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
Apache-2.0
public static JobCallbackManager getInstance() { if (!isInitialized) { throw new IllegalStateException(JobCallbackManager.class.getName() + " has not been initialized"); } return instance; }
Responsible processing job callback properties on job status change events. When job callback properties are specified, they will be converted to HTTP calls to execute. The HTTP requests will be made in asynchronous mode so the caller to the handleEvent method will not be block. In addition, the HTTP calls will be configured to time appropriately for connection request, creating connection, and socket timeout. The HTTP request and response will be logged out the job's log for debugging and traceability purpose. @author hluu
getInstance
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
Apache-2.0
public JmxJobCallbackMBean getJmxJobCallbackMBean() { return this.callbackMbean; }
Responsible processing job callback properties on job status change events. When job callback properties are specified, they will be converted to HTTP calls to execute. The HTTP requests will be made in asynchronous mode so the caller to the handleEvent method will not be block. In addition, the HTTP calls will be configured to time appropriately for connection request, creating connection, and socket timeout. The HTTP request and response will be logged out the job's log for debugging and traceability purpose. @author hluu
getJmxJobCallbackMBean
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
Apache-2.0
@Override public void handleEvent(final Event event) { if (!isInitialized) { return; } if (event.getRunner() instanceof JobRunnerBase) { JobRunnerBase jobRunnerBase = (JobRunnerBase) event.getRunner(); Props jobProps = jobRunnerBase.getProps(); Logger jobLogger = jobRunnerBase.getLogger(); try { if (event.getType() == EventType.JOB_STARTED) { processJobCallOnStart(event, jobProps, jobLogger); } else if (event.getType() == EventType.JOB_FINISHED) { processJobCallOnFinish(event, jobProps, jobLogger); } } catch (final Throwable e) { jobLogger.error( "Encountered error while handling job callback event", e); logger.warn("Error during handleEvent for event " + event.getData().getStatus() + ", " + "execId: " + event.getData().getExecutionId()); logger.warn(e.getMessage(), e); } } else { logger.warn("((( Got an unsupported runner: " + event.getRunner().getClass().getName() + " )))"); } }
Responsible processing job callback properties on job status change events. When job callback properties are specified, they will be converted to HTTP calls to execute. The HTTP requests will be made in asynchronous mode so the caller to the handleEvent method will not be block. In addition, the HTTP calls will be configured to time appropriately for connection request, creating connection, and socket timeout. The HTTP request and response will be logged out the job's log for debugging and traceability purpose. @author hluu
handleEvent
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
Apache-2.0
private void processJobCallOnFinish(final Event event, final Props jobProps, final Logger jobLogger) { final EventData eventData = event.getData(); if (!JobCallbackUtil.isThereJobCallbackProperty(jobProps, ON_COMPLETION_JOB_CALLBACK_STATUS)) { logger.info("No callback property for " + eventData.getStatus() + ", exec id: " + eventData.getExecutionId()); return; } // don't want to waste time resolving properties if there are no // callback properties to parse // resolve props in best effort. Ignore the case where a referenced property is undefined. final Props props = PropsUtils.resolveProps(jobProps, true); final Map<String, String> contextInfo = JobCallbackUtil.buildJobContextInfoMap(event, this.azkabanHostName); JobCallbackStatusEnum jobCallBackStatusEnum = null; final Status jobStatus = eventData.getStatus(); if (jobStatus == Status.SUCCEEDED) { jobCallBackStatusEnum = JobCallbackStatusEnum.SUCCESS; } else if (jobStatus == Status.FAILED || jobStatus == Status.FAILED_FINISHING || jobStatus == Status.KILLED || jobStatus == Status.EXECUTION_STOPPED) { jobCallBackStatusEnum = JobCallbackStatusEnum.FAILURE; } else { logger.info("!!!! WE ARE NOT SUPPORTING JOB CALLBACKS FOR STATUS: " + jobStatus); jobCallBackStatusEnum = null; // to be explicit } final String jobId = contextInfo.get(CONTEXT_JOB_TOKEN); if (jobCallBackStatusEnum != null) { final List<HttpRequestBase> jobCallbackHttpRequests = JobCallbackUtil.parseJobCallbackProperties(props, jobCallBackStatusEnum, contextInfo, maxNumCallBack, logger); if (!jobCallbackHttpRequests.isEmpty()) { final String msg = String.format("Making %d job callbacks for status: %s", jobCallbackHttpRequests.size(), jobCallBackStatusEnum.name()); logger.info(msg); addDefaultHeaders(jobCallbackHttpRequests); JobCallbackRequestMaker.getInstance().makeHttpRequest(jobId, logger, jobCallbackHttpRequests); } else { logger.info("No job callbacks for status: " + jobCallBackStatusEnum); } } // for completed status final List<HttpRequestBase> httpRequestsForCompletedStatus = JobCallbackUtil.parseJobCallbackProperties(props, COMPLETED, contextInfo, maxNumCallBack, logger); // now make the call if (!httpRequestsForCompletedStatus.isEmpty()) { jobLogger.info("Making " + httpRequestsForCompletedStatus.size() + " job callbacks for status: " + COMPLETED); addDefaultHeaders(httpRequestsForCompletedStatus); JobCallbackRequestMaker.getInstance().makeHttpRequest(jobId, logger, httpRequestsForCompletedStatus); } else { logger.info("No job callbacks for status: " + COMPLETED); } }
Responsible processing job callback properties on job status change events. When job callback properties are specified, they will be converted to HTTP calls to execute. The HTTP requests will be made in asynchronous mode so the caller to the handleEvent method will not be block. In addition, the HTTP calls will be configured to time appropriately for connection request, creating connection, and socket timeout. The HTTP request and response will be logged out the job's log for debugging and traceability purpose. @author hluu
processJobCallOnFinish
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
Apache-2.0
private void processJobCallOnStart(final Event event, final Props jobProps, final Logger jobLogger) { if (JobCallbackUtil.isThereJobCallbackProperty(jobProps, JobCallbackStatusEnum.STARTED)) { // don't want to waste time resolving properties if there are // callback properties to parse // resolve props in best effort. Ignore the case where a referenced property is undefined. final Props props = PropsUtils.resolveProps(jobProps, true); final Map<String, String> contextInfo = JobCallbackUtil.buildJobContextInfoMap(event, this.azkabanHostName); final List<HttpRequestBase> jobCallbackHttpRequests = JobCallbackUtil.parseJobCallbackProperties(props, STARTED, contextInfo, maxNumCallBack, logger); final String jobId = contextInfo.get(CONTEXT_JOB_TOKEN); final String msg = String.format("Making %d job callbacks for job %s for jobStatus: %s", jobCallbackHttpRequests.size(), jobId, STARTED.name()); jobLogger.info(msg); addDefaultHeaders(jobCallbackHttpRequests); JobCallbackRequestMaker.getInstance().makeHttpRequest(jobId, logger, jobCallbackHttpRequests); } }
Responsible processing job callback properties on job status change events. When job callback properties are specified, they will be converted to HTTP calls to execute. The HTTP requests will be made in asynchronous mode so the caller to the handleEvent method will not be block. In addition, the HTTP calls will be configured to time appropriately for connection request, creating connection, and socket timeout. The HTTP request and response will be logged out the job's log for debugging and traceability purpose. @author hluu
processJobCallOnStart
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
Apache-2.0
private String getAzkabanHostName(final Props props) { final String baseURL = props.get(AZKABAN_WEBSERVER_URL); try { // Refer to the web server configuration in AzkabanServer. String hostName = props.getString(JETTY_HOSTNAME, "localhost") + ":" + (props.getBoolean(JETTY_USE_SSL , true) ? props.getInt(JETTY_SSL_PORT, DEFAULT_SSL_PORT_NUMBER) : props.getInt(JETTY_PORT, DEFAULT_PORT_NUMBER)); if (baseURL != null) { final URL url = new URL(baseURL); hostName = url.getHost() + ":" + url.getPort(); } return hostName; } catch (final Exception e) { throw new IllegalStateException( "Encountered while getting azkaban host name", e); } }
Responsible processing job callback properties on job status change events. When job callback properties are specified, they will be converted to HTTP calls to execute. The HTTP requests will be made in asynchronous mode so the caller to the handleEvent method will not be block. In addition, the HTTP calls will be configured to time appropriately for connection request, creating connection, and socket timeout. The HTTP request and response will be logged out the job's log for debugging and traceability purpose. @author hluu
getAzkabanHostName
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
Apache-2.0
private void addDefaultHeaders(final List<HttpRequestBase> httpRequests) { if (httpRequests == null) { return; } final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"); format.setTimeZone(TimeZone.getTimeZone("GMT")); for (final HttpRequestBase httpRequest : httpRequests) { httpRequest.addHeader(new BasicHeader("Date", this.gmtDateFormatter .format(new Date()))); } }
Responsible processing job callback properties on job status change events. When job callback properties are specified, they will be converted to HTTP calls to execute. The HTTP requests will be made in asynchronous mode so the caller to the handleEvent method will not be block. In addition, the HTTP calls will be configured to time appropriately for connection request, creating connection, and socket timeout. The HTTP request and response will be logged out the job's log for debugging and traceability purpose. @author hluu
addDefaultHeaders
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackManager.java
Apache-2.0
public static void initialize(final Props props) { if (props == null) { throw new NullPointerException("props argument can't be null"); } if (isInitialized) { return; } instance = new JobCallbackRequestMaker(props); isInitialized = true; logger.info("Initialization for " + JobCallbackRequestMaker.class.getName() + " is completed"); }
Responsible for making the job callback HTTP requests. One of the requirements is to log out the request information and response using the given logger, which should be the job logger. @author hluu
initialize
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
Apache-2.0
public static boolean isInitialized() { return isInitialized; }
Responsible for making the job callback HTTP requests. One of the requirements is to log out the request information and response using the given logger, which should be the job logger. @author hluu
isInitialized
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
Apache-2.0
public static JobCallbackRequestMaker getInstance() { if (!isInitialized) { throw new IllegalStateException(JobCallbackRequestMaker.class.getName() + " hasn't initialzied"); } return instance; }
Responsible for making the job callback HTTP requests. One of the requirements is to log out the request information and response using the given logger, which should be the job logger. @author hluu
getInstance
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
Apache-2.0
public FutureRequestExecutionMetrics getJobcallbackMetrics() { return this.futureRequestExecutionService.metrics(); }
Responsible for making the job callback HTTP requests. One of the requirements is to log out the request information and response using the given logger, which should be the job logger. @author hluu
getJobcallbackMetrics
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
Apache-2.0
public void makeHttpRequest(final String jobId, final Logger logger, final List<HttpRequestBase> httpRequestList) { if (httpRequestList == null || httpRequestList.isEmpty()) { logger.info("No HTTP requests to make for: " + jobId); return; } for (final HttpRequestBase httpRequest : httpRequestList) { logger.debug("Job callback http request for " + jobId + ": " + httpRequest.toString()); logger.debug("headers ["); for (final Header header : httpRequest.getAllHeaders()) { logger.debug(String.format(" %s : %s", header.getName(), header.getValue())); } logger.debug("]"); final HttpRequestFutureTask<Integer> task = this.futureRequestExecutionService.execute(httpRequest, HttpClientContext.create(), new LoggingResponseHandler(logger)); for (int retryAttempt = 1; retryAttempt <= MAX_CALLBACK_RETRY_COUNT; retryAttempt++) { try { // get with timeout final Integer statusCode = task.get(this.responseWaitTimeoutMS, TimeUnit.MILLISECONDS); logger.info("http callback status code for " + jobId + ": " + statusCode); break; } catch (final TimeoutException timeOutEx) { logger .warn("Job callback target took longer " + (this.responseWaitTimeoutMS / 1000) + " seconds to respond for: " + jobId + ". Current retry attempt: " + retryAttempt + "/" + MAX_CALLBACK_RETRY_COUNT, timeOutEx); } catch (final ExecutionException ee) { if (ee.getCause() instanceof SocketTimeoutException) { logger.warn("Job callback target took longer " + (this.responseWaitTimeoutMS / 1000) + " seconds to respond" + ". Current retry attempt: " + retryAttempt + "/" + MAX_CALLBACK_RETRY_COUNT, ee); } else { logger.warn( "Failed to execute job callback for: " + jobId + ". Current retry attempt: " + retryAttempt + "/" + MAX_CALLBACK_RETRY_COUNT, ee); } } catch (final Throwable e) { logger.warn( "Failed to execute job callback for: " + jobId + ". Current retry attempt: " + retryAttempt + "/" + MAX_CALLBACK_RETRY_COUNT, e); } try { Thread.sleep(CALLBACK_RETRY_INTERVAL_MS); } catch (final InterruptedException e) { logger.error("Sleep interrupted", e); } } } }
Responsible for making the job callback HTTP requests. One of the requirements is to log out the request information and response using the given logger, which should be the job logger. @author hluu
makeHttpRequest
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
Apache-2.0
@Override public Integer handleResponse(final HttpResponse response) throws ClientProtocolException, IOException { final int statusCode = response.getStatusLine().getStatusCode(); BufferedReader bufferedReader = null; try { final HttpEntity responseEntity = response.getEntity(); if (responseEntity != null) { bufferedReader = new BufferedReader(new InputStreamReader( responseEntity.getContent(), StandardCharsets.UTF_8)); String line = ""; int lineCount = 0; this.logger.info("HTTP response ["); while ((line = bufferedReader.readLine()) != null) { this.logger.info(line); lineCount++; if (lineCount > MAX_RESPONSE_LINE_TO_PRINT) { break; } } this.logger.info("]"); } else { this.logger.info("No response"); } } catch (final Throwable t) { this.logger.warn( "Encountered error while logging out job callback response", t); } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch (final IOException ex) { // don't care } } } return statusCode; }
Response handler for logging job callback response using the given logger instance @author hluu
handleResponse
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackRequestMaker.java
Apache-2.0
public static boolean isThereJobCallbackProperty(final Props props, final JobCallbackStatusEnum status) { if (props == null || status == null) { throw new NullPointerException("One of the argument is null"); } final String jobCallBackUrl = firstJobcallbackPropertyMap.get(status); return props.containsKey(jobCallBackUrl); }
Use to quickly determine if there is a job callback related property in the Props. @return true if there is job callback related property
isThereJobCallbackProperty
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
public static boolean isThereJobCallbackProperty(final Props props, final JobCallbackStatusEnum... jobStatuses) { if (props == null || jobStatuses == null) { throw new NullPointerException("One of the argument is null"); } for (final JobCallbackStatusEnum jobStatus : jobStatuses) { if (JobCallbackUtil.isThereJobCallbackProperty(props, jobStatus)) { return true; } } return false; }
Use to quickly determine if there is a job callback related property in the Props. @return true if there is job callback related property
isThereJobCallbackProperty
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
public static List<HttpRequestBase> parseJobCallbackProperties(final Props props, final JobCallbackStatusEnum status, final Map<String, String> contextInfo, final int maxNumCallback) { return parseJobCallbackProperties(props, status, contextInfo, maxNumCallback, logger); }
Use to quickly determine if there is a job callback related property in the Props. @return true if there is job callback related property
parseJobCallbackProperties
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
public static List<HttpRequestBase> parseJobCallbackProperties(final Props props, final JobCallbackStatusEnum status, final Map<String, String> contextInfo, final int maxNumCallback, final Logger privateLogger) { String callbackUrl = null; if (!isThereJobCallbackProperty(props, status)) { // short circuit return Collections.emptyList(); } final List<HttpRequestBase> result = new ArrayList<>(); // replace property templates with status final String jobCallBackUrlKey = replaceStatusToken(JOB_CALLBACK_URL_TEMPLATE, status); final String requestMethod = replaceStatusToken(JOB_CALLBACK_REQUEST_METHOD_TEMPLATE, status); final String httpBodyKey = replaceStatusToken(JOB_CALLBACK_BODY_TEMPLATE, status); final String headersKey = replaceStatusToken(JOB_CALLBACK_REQUEST_HEADERS_TEMPLATE, status); for (int sequence = 1; sequence <= maxNumCallback; sequence++) { HttpRequestBase httpRequest = null; final String sequenceStr = Integer.toString(sequence); // callback url final String callbackUrlKey = jobCallBackUrlKey.replace(SEQUENCE_TOKEN, sequenceStr); callbackUrl = props.get(callbackUrlKey); if (callbackUrl == null || callbackUrl.length() == 0) { // no more needs to done break; } else { final String callbackUrlWithTokenReplaced = replaceTokens(callbackUrl, contextInfo, true); final String requestMethodKey = requestMethod.replace(SEQUENCE_TOKEN, sequenceStr); final String method = props.getString(requestMethodKey, HTTP_GET); if (HTTP_POST.equals(method)) { final String postBodyKey = httpBodyKey.replace(SEQUENCE_TOKEN, sequenceStr); final String httpBodyValue = props.get(postBodyKey); if (httpBodyValue == null) { // missing body for POST, not good // update the wiki about skipping callback url if body is missing privateLogger.warn("Missing value for key: " + postBodyKey + " skipping job callback '" + callbackUrl + " for job " + contextInfo.get(CONTEXT_JOB_TOKEN)); } else { // put together an URL privateLogger.info("callbackUrlWithTokenReplaced: " + callbackUrlWithTokenReplaced); final HttpPost httpPost = new HttpPost(callbackUrlWithTokenReplaced); final String postActualBody = replaceTokens(httpBodyValue, contextInfo, false); privateLogger.info("postActualBody: " + postActualBody); httpPost.setEntity(createStringEntity(postActualBody)); httpRequest = httpPost; } } else if (HTTP_GET.equals(method)) { // GET httpRequest = new HttpGet(callbackUrlWithTokenReplaced); } else { privateLogger.warn("Unsupported request method: " + method + ". Only POST and GET are supported"); } final String headersKeyPerSequence = headersKey.replace(SEQUENCE_TOKEN, sequenceStr); final String headersValue = props.get(headersKeyPerSequence); privateLogger.info("headers: " + headersValue); final Header[] headers = parseHttpHeaders(headersValue); if (headers != null) { httpRequest.setHeaders(headers); privateLogger.info("# of headers found: " + headers.length); } result.add(httpRequest); } } return result; }
This method is responsible for parsing job call URL properties and convert them into a list of HttpRequestBase, which callers can use to execute. In addition to parsing, it will also replace the tokens with actual values. @return List<HttpRequestBase> - empty if no job callback related properties
parseJobCallbackProperties
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
public static Header[] parseHttpHeaders(final String headers) { if (headers == null || headers.length() == 0) { return null; } final String[] headerArray = headers.split(HEADER_ELEMENT_DELIMITER); final List<Header> headerList = new ArrayList<>(headerArray.length); for (int i = 0; i < headerArray.length; i++) { final String headerPair = headerArray[i]; final int index = headerPair.indexOf(HEADER_NAME_VALUE_DELIMITER); if (index != -1) { headerList.add(new BasicHeader(headerPair.substring(0, index), headerPair.substring(index + 1))); } } return headerList.toArray(new BasicHeader[0]); }
Parse headers @return null if headers is null or empty
parseHttpHeaders
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
private static String replaceStatusToken(final String template, final JobCallbackStatusEnum status) { return template.replaceAll(STATUS_TOKEN, status.name().toLowerCase()); }
Parse headers @return null if headers is null or empty
replaceStatusToken
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
private static StringEntity createStringEntity(final String str) { try { return new StringEntity(str); } catch (final UnsupportedEncodingException e) { throw new RuntimeException("Encoding not supported", e); } }
Parse headers @return null if headers is null or empty
createStringEntity
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
public static Map<String, String> buildJobContextInfoMap(final Event event, final String server) { final EventData eventData = event.getData(); final String projectName = eventData.getProjectName(); final String flowName = eventData.getFlowName(); final String executionId = String.valueOf(eventData.getExecutionId()); final String jobId = eventData.getJobId(); final Map<String, String> result = new HashMap<>(); result.put(CONTEXT_SERVER_TOKEN, server); result.put(CONTEXT_PROJECT_TOKEN, projectName); result.put(CONTEXT_FLOW_TOKEN, flowName); result.put(CONTEXT_EXECUTION_ID_TOKEN, executionId); result.put(CONTEXT_JOB_TOKEN, jobId); result.put(CONTEXT_JOB_STATUS_TOKEN, eventData.getStatus().name().toLowerCase()); /* * if (node.getStatus() == Status.SUCCEEDED || node.getStatus() == * Status.FAILED) { result.put(JOB_STATUS_TOKEN, * node.getStatus().name().toLowerCase()); } else if (node.getStatus() == * Status.PREPARING) { result.put(JOB_STATUS_TOKEN, "started"); } */ return result; }
This method takes the job context info. and put the values into a map with keys as the tokens. @return Map<String,String>
buildJobContextInfoMap
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
public static String replaceTokens(final String value, final Map<String, String> contextInfo, final boolean withEncoding) { String result = value; String tokenValue = encodeQueryParam(contextInfo.get(CONTEXT_SERVER_TOKEN), withEncoding); result = result.replaceAll(Pattern.quote(CONTEXT_SERVER_TOKEN), tokenValue); tokenValue = encodeQueryParam(contextInfo.get(CONTEXT_PROJECT_TOKEN), withEncoding); result = result.replaceAll(Pattern.quote(CONTEXT_PROJECT_TOKEN), tokenValue); tokenValue = encodeQueryParam(contextInfo.get(CONTEXT_FLOW_TOKEN), withEncoding); result = result.replaceAll(Pattern.quote(CONTEXT_FLOW_TOKEN), tokenValue); tokenValue = encodeQueryParam(contextInfo.get(CONTEXT_JOB_TOKEN), withEncoding); result = result.replaceAll(Pattern.quote(CONTEXT_JOB_TOKEN), tokenValue); tokenValue = encodeQueryParam(contextInfo.get(CONTEXT_EXECUTION_ID_TOKEN), withEncoding); result = result.replaceAll(Pattern.quote(CONTEXT_EXECUTION_ID_TOKEN), tokenValue); tokenValue = encodeQueryParam(contextInfo.get(CONTEXT_JOB_STATUS_TOKEN), withEncoding); result = result.replaceAll(Pattern.quote(CONTEXT_JOB_STATUS_TOKEN), tokenValue); return result; }
Replace the supported tokens in the URL with values in the contextInfo. This will also make sure the values are HTTP encoded. @param withEncoding - whether the token values will be HTTP encoded @return String - value with tokens replaced with values
replaceTokens
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
private static String encodeQueryParam(final String str, final boolean withEncoding) { if (!withEncoding) { return str; } try { return URLEncoder.encode(str, "UTF-8"); } catch (final UnsupportedEncodingException e) { throw new IllegalArgumentException( "Encountered problem during encoding:", e); } }
Replace the supported tokens in the URL with values in the contextInfo. This will also make sure the values are HTTP encoded. @param withEncoding - whether the token values will be HTTP encoded @return String - value with tokens replaced with values
encodeQueryParam
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackUtil.java
Apache-2.0
public static int validate(final String jobName, final Props serverProps, final Props jobProps, final Collection<String> errors) { final int maxNumCallback = serverProps.getInt( JobCallbackConstants.MAX_CALLBACK_COUNT_PROPERTY_KEY, JobCallbackConstants.DEFAULT_MAX_CALLBACK_COUNT); final int maxPostBodyLength = serverProps.getInt(MAX_POST_BODY_LENGTH_PROPERTY_KEY, DEFAULT_POST_BODY_LENGTH); int totalCallbackCount = 0; for (final JobCallbackStatusEnum jobStatus : JobCallbackStatusEnum.values()) { totalCallbackCount += validateBasedOnStatus(jobProps, errors, jobStatus, maxNumCallback, maxPostBodyLength); } if (logger.isDebugEnabled()) { logger.debug("Found " + totalCallbackCount + " job callbacks for job " + jobName); } return totalCallbackCount; }
Make sure all the job callback related properties are valid @return number of valid job callback properties. Mainly for testing purpose.
validate
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackValidator.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackValidator.java
Apache-2.0
private static int validateBasedOnStatus(final Props jobProps, final Collection<String> errors, final JobCallbackStatusEnum jobStatus, final int maxNumCallback, final int maxPostBodyLength) { int callbackCount = 0; // replace property templates with status final String jobCallBackUrl = JOB_CALLBACK_URL_TEMPLATE.replaceFirst(STATUS_TOKEN, jobStatus.name() .toLowerCase()); final String requestMethod = JOB_CALLBACK_REQUEST_METHOD_TEMPLATE.replaceFirst(STATUS_TOKEN, jobStatus.name().toLowerCase()); final String httpBody = JOB_CALLBACK_BODY_TEMPLATE.replaceFirst(STATUS_TOKEN, jobStatus.name() .toLowerCase()); for (int i = 0; i <= maxNumCallback; i++) { // callback url final String callbackUrlKey = jobCallBackUrl.replaceFirst(SEQUENCE_TOKEN, Integer.toString(i)); final String callbackUrlValue = jobProps.get(callbackUrlKey); // sequence number should start at 1, this is to check for sequence // number that starts a 0 if (i == 0) { if (callbackUrlValue != null) { errors.add("Sequence number starts at 1, not 0"); } continue; } if (callbackUrlValue == null || callbackUrlValue.length() == 0) { break; } else { final String requestMethodKey = requestMethod.replaceFirst(SEQUENCE_TOKEN, Integer.toString(i)); final String methodValue = jobProps.getString(requestMethodKey, HTTP_GET); if (HTTP_POST.equals(methodValue)) { // now try to get the post body final String postBodyKey = httpBody.replaceFirst(SEQUENCE_TOKEN, Integer.toString(i)); final String postBodyValue = jobProps.get(postBodyKey); if (postBodyValue == null || postBodyValue.length() == 0) { errors.add("No POST body was specified for job callback '" + callbackUrlValue + "'"); } else if (postBodyValue.length() > maxPostBodyLength) { errors.add("POST body length is : " + postBodyValue.length() + " which is larger than supported length of " + maxPostBodyLength); } else { callbackCount++; } } else if (HTTP_GET.equals(methodValue)) { // that's cool callbackCount++; } else { errors.add("Unsupported request method: " + methodValue + " Only POST and GET are supported"); } } } return callbackCount; }
Make sure all the job callback related properties are valid @return number of valid job callback properties. Mainly for testing purpose.
validateBasedOnStatus
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackValidator.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobcallback/JobCallbackValidator.java
Apache-2.0
@Deprecated public File createOutputPropsFile(final String id, final String workingDir) { this.info("cwd=" + workingDir); try { final File directory = new File(workingDir); final File tempFile = File.createTempFile(id + "_output_", "_tmp", directory); return tempFile; } catch (final IOException e) { this.error("Failed to create temp output property file :", e); throw new RuntimeException("Failed to create temp output property file ", e); } }
This public function will be deprecated since it tends to be a Utility Function Please use azkaban.utils.FileIOUtils.createOutputPropsFile(String, String, String) instead.
createOutputPropsFile
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public Props getJobProps() { return this.jobProps; }
This public function will be deprecated since it tends to be a Utility Function Please use azkaban.utils.FileIOUtils.createOutputPropsFile(String, String, String) instead.
getJobProps
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public Props getSysProps() { return this.sysProps; }
This public function will be deprecated since it tends to be a Utility Function Please use azkaban.utils.FileIOUtils.createOutputPropsFile(String, String, String) instead.
getSysProps
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public void setJobProps(Props props) { this.jobProps = props; }
Re-configure Job Props @param props new props
setJobProps
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public void setSysProps(Props props) { this.sysProps = props; }
Re-configure System Props @param props props
setSysProps
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public Props getAllProps() { Props props = new Props(); props.putAll(jobProps); props.putAll(sysProps); return appendExtraProps(props); }
Re-configure System Props @param props props
getAllProps
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public Props appendExtraProps(Props props) { return props; }
Re-configure System Props @param props props
appendExtraProps
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public String getJobPath() { return this._jobPath; }
Re-configure System Props @param props props
getJobPath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
protected void resolveProps() { this.jobProps = PropsUtils.resolveProps(this.jobProps); }
Re-configure System Props @param props props
resolveProps
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
protected void logJobProperties() { if (this.jobProps != null && this.jobProps.getBoolean(JOB_DUMP_PROPERTIES_IN_LOG, false)) { try { final Map<String, String> flattenedProps = this.jobProps.getFlattened(); this.info("****** Job properties ******"); this.info(String.format("- Note : value is masked if property name ends with '%s'.", SENSITIVE_JOB_PROP_NAME_SUFFIX)); for (final Map.Entry<String, String> entry : flattenedProps.entrySet()) { final String key = entry.getKey(); final String value = key.endsWith(SENSITIVE_JOB_PROP_NAME_SUFFIX) ? SENSITIVE_JOB_PROP_VALUE_PLACEHOLDER : entry.getValue(); this.info(String.format("%s=%s", key, value)); } this.info("****** End Job properties ******"); } catch (final Exception ex) { this.error("failed to log job properties ", ex); } } }
prints the current Job props to the Job log.
logJobProperties
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
@Override public Props getJobGeneratedProperties() { return this.generatedProperties; }
prints the current Job props to the Job log.
getJobGeneratedProperties
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public File[] initPropsFiles() { // Create job properties file with additionally all input generated properties. final File[] files = new File[3]; files[0] = createFlattenedPropsFile(this.jobProps, this._cwd, "_job_props_"); this.jobProps.put(ENV_PREFIX + JOB_PROP_ENV, files[0].getAbsolutePath()); this.jobProps.put(ENV_PREFIX + JOB_NAME_ENV, getId()); files[1] = createOutputPropsFile(getId(), this._cwd); this.jobProps.put(ENV_PREFIX + JOB_OUTPUT_PROP_FILE, files[1].getAbsolutePath()); // Create job's private properties file. if (this.privateProps != null) { files[2] = createFlattenedPropsFile(this.privateProps, this._cwd, "_job_private_props_"); this.jobProps.put(ENV_PREFIX + JOBTYPE_PRIVATE_PROP_ENV, files[2].getAbsolutePath()); } return files; }
initialize temporary and final property file @return {tmpPropFile, outputPropFile}
initPropsFiles
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public String getCwd() { return this._cwd; }
initialize temporary and final property file @return {tmpPropFile, outputPropFile}
getCwd
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public Map<String, String> getEnvironmentVariables() { final Props props = getJobProps(); final Map<String, String> envMap = props.getMapByPrefix(ENV_PREFIX); return envMap; }
Get Environment Variables from the Job Properties Table @return All Job Properties with "env." prefix
getEnvironmentVariables
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
public String getWorkingDirectory() { final String workingDir = getJobProps().getString(WORKING_DIR, this._jobPath); return Utils.ifNull(workingDir, ""); }
Get Working Directory from Job Properties when it is presented. Otherwise, the working directory is the jobPath @return working directory property
getWorkingDirectory
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
@Deprecated public Props loadOutputFileProps(final File outputPropertiesFile) { InputStream reader = null; try { this.info("output properties file=" + outputPropertiesFile.getAbsolutePath()); reader = new BufferedInputStream(new FileInputStream(outputPropertiesFile)); final Props outputProps = new Props(); final String content = Streams.asString(reader).trim(); if (!content.isEmpty()) { final Map<String, Object> propMap = (Map<String, Object>) JSONUtils.parseJSONFromString(content); for (final Map.Entry<String, Object> entry : propMap.entrySet()) { outputProps.put(entry.getKey(), entry.getValue().toString()); } } return outputProps; } catch (final FileNotFoundException e) { this.info( String.format("File[%s] wasn't found, returning empty props.", outputPropertiesFile)); return new Props(); } catch (final Exception e) { this.error( "Exception thrown when trying to load output file props. Returning empty Props instead of failing. Is this really the best thing to do?", e); return new Props(); } finally { IOUtils.closeQuietly(reader); } }
This public function will be deprecated since it tends to be a Utility function Please use azkaban.utils.FileIOUtils.loadOutputFileProps(String file) instead.
loadOutputFileProps
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
@Deprecated private File createFlattenedPropsFile(final Props props, final String workingDir, String propsName) { try { final File directory = new File(workingDir); // The temp file prefix must be at least 3 characters. final File tempFile = File.createTempFile(getId() + propsName, "_tmp", directory); props.storeFlattened(tempFile); return tempFile; } catch (final IOException e) { throw new RuntimeException("Failed to create temp property file. workingDir = " + workingDir); } }
This public function will be deprecated since it tends to be a Utility function Please use azkaban.utils.FileIOUtils.createOutputPropsFile(String, String, String) instead.
createFlattenedPropsFile
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
protected void generateProperties(final File outputFile) { this.generatedProperties = loadOutputFileProps(outputFile); }
Generate properties from output file and set to props tables @param outputFile explain
generateProperties
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/AbstractProcessJob.java
Apache-2.0
@Override public URL getResource(final String name) { URL url = findResource(name); // borrowed from Hadoop, if the resource that starts with '/' is not found, and tries again // with the leading '/' removed, in case the resource name was incorrectly specified if (url == null && name.startsWith("/")) { LOG.debug("Remove leading / off " + name); url = findResource(name.substring(1)); } if (url == null) { url = this.parent.getResource(name); } if (url != null) { LOG.debug("getResource(" + name + ")=" + url + " for job " + this.jobId); } return url; }
Try to load resources from this classloader's URLs. Note that this is like the servlet spec, not the usual Java behaviour where we ask the parent classloader to attempt to load first.
getResource
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/JobClassLoader.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/JobClassLoader.java
Apache-2.0
@Override public Class<?> loadClass(final String name) throws ClassNotFoundException { return this.loadClass(name, false); }
Try to load resources from this classloader's URLs. Note that this is like the servlet spec, not the usual Java behaviour where we ask the parent classloader to attempt to load first.
loadClass
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/jobExecutor/JobClassLoader.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/jobExecutor/JobClassLoader.java
Apache-2.0