Skip to content

Commit

Permalink
CDAP-20858 checkstyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
albertshau committed Nov 2, 2023
1 parent 3804da1 commit b6fb2e6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import javax.annotation.Nullable;

/**
* Dataproc related metric
* Dataproc related metric.
*/
public class DataprocMetric {
private final String region;
Expand Down Expand Up @@ -98,6 +98,7 @@ public Builder setLaunchMode(@Nullable LaunchMode launchMode) {

/**
* Returns a DataprocMetric.
*
* @return DataprocMetric.
*/
public DataprocMetric build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ private static void updateTemporaryHoldOnGcsObject(Storage storage, String bucke
}
}

/**
* Get a user friendly message pointing to an external troubleshooting doc.
*
* @param troubleshootingDocsUrl Url for the troubleshooting doc
* @return user friendly message pointing to an external troubleshooting doc.
*/
public static String getTroubleshootingHelpMessage(@Nullable String troubleshootingDocsUrl) {
if (Strings.isNullOrEmpty(troubleshootingDocsUrl)) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ private LocalFile uploadCacheableFile(String bucket, String targetFilePath,
try {
LOG.debug("Uploading a file of size {} bytes from {} to gs://{}/{}",
localFile.getSize(), localFile.getURI(), bucket, targetFilePath);
uploadToGCSUtil(localFile, storage, targetFilePath, newBlobInfo,
uploadToGcsUtil(localFile, storage, targetFilePath, newBlobInfo,
Storage.BlobWriteOption.generationMatch(),
Storage.BlobWriteOption.metagenerationMatch());
} catch (StorageException e) {
Expand Down Expand Up @@ -600,7 +600,7 @@ private LocalFile uploadFile(String bucket, String targetFilePath,
localFile.getSize(), localFile.getURI(), bucket, targetFilePath,
bucketObj.getLocationType(), bucketObj.getLocation());
try {
uploadToGCSUtil(localFile, storage, targetFilePath, blobInfo,
uploadToGcsUtil(localFile, storage, targetFilePath, blobInfo,
Storage.BlobWriteOption.doesNotExist());
} catch (StorageException e) {
if (e.getCode() != HttpURLConnection.HTTP_PRECON_FAILED) {
Expand All @@ -613,7 +613,7 @@ private LocalFile uploadFile(String bucket, String targetFilePath,
// Overwrite the file
Blob existingBlob = storage.get(blobId);
BlobInfo newBlobInfo = existingBlob.toBuilder().setContentType(contentType).build();
uploadToGCSUtil(localFile, storage, targetFilePath, newBlobInfo,
uploadToGcsUtil(localFile, storage, targetFilePath, newBlobInfo,
Storage.BlobWriteOption.generationNotMatch());
} else {
LOG.debug("Skip uploading file {} to gs://{}/{} because it exists.",
Expand All @@ -637,11 +637,11 @@ private long getCustomTime() {
/**
* Uploads the file to GCS Bucket.
*/
private void uploadToGCSUtil(LocalFile localFile, Storage storage, String targetFilePath,
private void uploadToGcsUtil(LocalFile localFile, Storage storage, String targetFilePath,
BlobInfo blobInfo,
Storage.BlobWriteOption... blobWriteOptions) throws IOException, StorageException {
long start = System.nanoTime();
uploadToGCS(localFile.getURI(), storage, blobInfo, blobWriteOptions);
uploadToGcs(localFile.getURI(), storage, blobInfo, blobWriteOptions);
long end = System.nanoTime();
LOG.debug("Successfully uploaded file {} to gs://{}/{} in {} ms.",
localFile.getURI(), bucket, targetFilePath, TimeUnit.NANOSECONDS.toMillis(end - start));
Expand All @@ -650,7 +650,7 @@ private void uploadToGCSUtil(LocalFile localFile, Storage storage, String target
/**
* Uploads the file to GCS bucket.
*/
private void uploadToGCS(java.net.URI localFileUri, Storage storage, BlobInfo blobInfo,
private void uploadToGcs(java.net.URI localFileUri, Storage storage, BlobInfo blobInfo,
Storage.BlobWriteOption... blobWriteOptions) throws IOException, StorageException {
try (InputStream inputStream = openStream(localFileUri);
WriteChannel writer = storage.writer(blobInfo, blobWriteOptions)) {
Expand Down Expand Up @@ -753,6 +753,17 @@ private SubmitJobRequest getSubmitJobRequest(RuntimeJobInfo runtimeJobInfo,
.build();
}

/**
* Get the list of arguments to pass to the runtime job on the command line.
* The DataprocJobMain argument is [class-name] [spark-compat] [list of archive files...]
*
* @param runtimeJobInfo information about the runtime job
* @param localFiles files to localize
* @param sparkCompat spark compat version
* @param applicationJarLocalizedName localized application jar name
* @param launchMode launch mode for the job
* @return list of arguments to pass to the runtime job on the command line
*/
@VisibleForTesting
public static List<String> getArguments(RuntimeJobInfo runtimeJobInfo, List<LocalFile> localFiles,
String sparkCompat, String applicationJarLocalizedName,
Expand All @@ -773,6 +784,12 @@ public static List<String> getArguments(RuntimeJobInfo runtimeJobInfo, List<Loca
return arguments;
}

/**
* Get the property map that should be set for the Dataproc Hadoop Job.
*
* @param runtimeJobInfo information about the runtime job
* @return property map that should be set for the Dataproc Hadoop Job
*/
@VisibleForTesting
public static Map<String, String> getProperties(RuntimeJobInfo runtimeJobInfo) {
ProgramRunInfo runInfo = runtimeJobInfo.getProgramRunInfo();
Expand Down Expand Up @@ -870,9 +887,9 @@ private String getPath(String... pathSubComponents) {
/**
* Returns job name from run info. namespace, application, program, run(36 characters) Example:
* namespace_application_program_8e1cb2ce-a102-48cf-a959-c4f991a2b475
* <p>
* The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), or hyphens (-).
* The maximum length is 100 characters.
*
* <p>The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), or hyphens (-).
* The maximum length is 100 characters.</p>
*
* @throws IllegalArgumentException if provided id does not comply with naming restrictions
*/
Expand Down

0 comments on commit b6fb2e6

Please sign in to comment.