1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | package Torello.Java.Build; import Torello.Java.GSUTIL; import Torello.Java.Shell; import Torello.Java.OSResponse; import Torello.Java.UnreachableError; import Torello.JDUInternal.ParseJavaSource.JavaSourceCodeFile; import java.io.IOException; import java.io.File; /** * This is the seventh Build-Stage, and it is part of the synchronization of a project with Google * Cloud Platform Stroage Buckets. This class relies heavily on the GCP Shell-Command * {@code 'gsutil'} and it's Java implementation - {@link GSUTIL Torello.Java.GSUTIL}. * * <BR /><BR />This class' synchronization-efforts entail copying the local / File-System * Log-Files onto the (User-Specified) Google Cloud Server Storage-Bucket. * * <EMBED CLASS='external-html' DATA-FILE-ID=S07_SYNC_LOGS> */ @Torello.JavaDoc.StaticFunctional public class S07_SyncLogs { // Completely irrelevant, and the 'private' modifier keeps it off of JavaDoc private S07_SyncLogs() { } // ******************************************************************************************** // ******************************************************************************************** // Copies The Log Files to GCS // ******************************************************************************************** // ******************************************************************************************** public static void sync(Builder builder) throws IOException { builder.timers.startStage07(); Printing.startStep(7); final String CLOUD_LOG_DIR = builder.cli.GCS_DIR + "logs/"; // Uses Shell-Contructor: // (outputAppendable, commandStrAppendable, standardOutput, errorOutput) // GSUTIL gsutil = new GSUTIL(System.out, System.out, null, null); builder.cloudSync.initStage07(); // OSResponse osr = gsutil.CP(builder.logs.LOG_DIR + '*', GCS_LOG_DIR); OSResponse osr = builder.cloudSync.copyLogDirToCloud(CLOUD_LOG_DIR); Util.HALT_ON_ERROR(osr); System.out.println(); // osr = gsutil.CONTENT_TYPE(GCS_LOG_DIR + "*.html", GSUTIL.SCT_HTML_UTF8); osr = builder.cloudSync.setCloudLogsContentType(CLOUD_LOG_DIR); Util.HALT_ON_ERROR(osr); System.out.println(); // JavaHTML.torello.directory has bucket-level public access if (builder.RUN_MAKE_PUBLIC) { // osr = gsutil.MP(CLOUD_LOG_DIR + "*"); osr = builder.cloudSync.makeLogsPublic(CLOUD_LOG_DIR); Util.HALT_ON_ERROR(osr); System.out.println(); } builder.cloudSync.endStage07(); builder.timers.endStage07(); } // ******************************************************************************************** // ******************************************************************************************** // NEW FEATURE: Copy the "TestAll Log" // ******************************************************************************************** // ******************************************************************************************** static void copyDebuggerLogs(Builder builder, byte LOG_KIND) throws IOException { builder.timers.startStage07(); // Uses Shell-Contructor: // (outputAppendable, commandStrAppendable, standardOutput, errorOutput) final GSUTIL gsutil = new GSUTIL(System.out, System.out, null, null); final Shell shell = new Shell(System.out, System.out, null, null); OSResponse osr = null; if (new File(Torello.Test.TestAll.TEST_ALL_OUTPUT_FILENAME).exists()) { osr = shell.MV(Torello.Test.TestAll.TEST_ALL_OUTPUT_FILENAME, builder.logs.LOG_DIR); Util.HALT_ON_ERROR(osr); System.out.println(); } final String fName = builder.logs.LOG_DIR + Torello.Test.TestAll.TEST_ALL_OUTPUT_FILENAME; final String gcsName = builder.cli.GCS_DIR + "logs/" + fName; osr = gsutil.CP(fName, gcsName); Util.HALT_ON_ERROR(osr); System.out.println(); osr = gsutil.CONTENT_TYPE(gcsName, GSUTIL.SCT_HTML_UTF8); Util.HALT_ON_ERROR(osr); System.out.println(); if (! builder.RUN_MAKE_PUBLIC) { osr = gsutil.MP(gcsName); Util.HALT_ON_ERROR(osr); System.out.println(); } // For old time's sake, this is how it has always been done. Why change it now? if (! builder.cli.toReleaseOrDeveloper) { osr = gsutil.SMA(gcsName, 100); Util.HALT_ON_ERROR(osr); System.out.println(); } System.out.println("View Log File:\n\nhttp://" + gcsName.substring(5) + "\n"); builder.timers.endStage07(); } } |