/** * Gets the hour metrics table for a specific storage service. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @return * The {@link CloudTable} object for the storage service. * @throws URISyntaxException * @throws StorageException */ public CloudTable getHourMetricsTable(StorageService service) throws URISyntaxException, StorageException { return this.getHourMetricsTable(service, null); }
/** * Gets the minute metrics table for a specific storage service. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @return * The {@link CloudTable} object for the storage service. * @throws URISyntaxException * @throws StorageException */ public CloudTable getMinuteMetricsTable(StorageService service) throws URISyntaxException, StorageException { return this.getMinuteMetricsTable(service, null); }
/** * Returns an enumerable collection of log blobs, retrieved lazily. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @return * An enumerable collection of objects that implement <code>ListBlobItem</code> and are retrieved lazily. * @throws URISyntaxException * @throws StorageException */ public Iterable<ListBlobItem> listLogBlobs(StorageService service) throws URISyntaxException, StorageException { return this.listLogBlobs(service, null /* startTime */, null /* endTime */, null /* operations */, null /* details */, null /* options */, null /* operationContext */); }
CloudTable blobHourPrimary = this.client.getHourMetricsTable(StorageService.BLOB); CloudTable blobHourSecondary = this.client.getHourMetricsTable(StorageService.BLOB, StorageLocation.SECONDARY); CloudTable fileHourPrimary = this.client.getHourMetricsTable(StorageService.FILE); CloudTable fileHourSecondary = this.client.getHourMetricsTable(StorageService.FILE, StorageLocation.SECONDARY); CloudTable queueHourPrimary = this.client.getHourMetricsTable(StorageService.QUEUE, StorageLocation.PRIMARY); CloudTable queueHourSecondary = this.client.getHourMetricsTable(StorageService.QUEUE, StorageLocation.SECONDARY); CloudTable tableHourPrimary = this.client.getHourMetricsTable(StorageService.TABLE, StorageLocation.PRIMARY); CloudTable tableHourSecondary = this.client.getHourMetricsTable(StorageService.TABLE, StorageLocation.SECONDARY); CloudTable blobMinutePrimary = this.client.getMinuteMetricsTable(StorageService.BLOB); CloudTable blobMinuteSecondary = this.client.getMinuteMetricsTable(StorageService.BLOB, StorageLocation.SECONDARY); CloudTable fileMinutePrimary = this.client.getMinuteMetricsTable(StorageService.FILE); CloudTable fileMinuteSecondary = this.client.getMinuteMetricsTable(StorageService.FILE, StorageLocation.SECONDARY); CloudTable queueMinutePrimary = this.client.getMinuteMetricsTable(StorageService.QUEUE, StorageLocation.PRIMARY); CloudTable queueMinuteSecondary = this.client.getMinuteMetricsTable(StorageService.QUEUE, StorageLocation.SECONDARY); CloudTable tableMinutePrimary = this.client.getMinuteMetricsTable(StorageService.TABLE, StorageLocation.PRIMARY); CloudTable tableMinuteSecondary = this.client.getMinuteMetricsTable(StorageService.TABLE, StorageLocation.SECONDARY); CloudTable capacity = this.client.getCapacityTable();
/** * Returns an enumerable collection of log records, retrieved lazily. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @return * An enumerable collection of objects that implement <code>ListBlobItem</code> and are retrieved lazily. * @throws URISyntaxException * @throws StorageException */ public Iterable<LogRecord> listLogRecords(StorageService service) throws URISyntaxException, StorageException { return this .listLogRecords(service, null /* startTime */, null /* endTime */, null /* options */, null /* operationContext */); }
/** * Returns an enumerable collection of log records, retrieved lazily. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @param startTime * A <code>java.util.Date</code> object representing the start of the time range for which logs should * be retrieved. * @param endTime * A <code>java.util.Date</code> object representing the end of the time range for which logs should * be retrieved. * @param options * A {@link BlobRequestOptions} object that specifies additional options for the request. * @param operationContext * An {@link OperationContext} object that represents the context for the current operation. * @return * An enumerable collection of objects that implement {@link ListBlobItem} and are retrieved lazily. * @throws StorageException * @throws URISyntaxException */ public Iterable<LogRecord> listLogRecords(StorageService service, Date startTime, Date endTime, BlobRequestOptions options, OperationContext operationContext) throws StorageException, URISyntaxException { Utility.assertNotNull("service", service); EnumSet<LoggingOperations> operations = EnumSet.allOf(LoggingOperations.class); EnumSet<BlobListingDetails> metadataDetails = EnumSet.noneOf(BlobListingDetails.class); Iterator<ListBlobItem> blobIterator = new LogBlobIterable(this.getLogDirectory(service), startTime, endTime, operations, metadataDetails, options, operationContext).iterator(); return new LogRecordIterable(blobIterator); }
/** * Creates a new Analytics service client. * * @return An analytics client object that uses the Blob and Table service endpoints. */ public CloudAnalyticsClient createCloudAnalyticsClient() { if (this.getBlobStorageUri() == null) { throw new IllegalArgumentException(SR.BLOB_ENDPOINT_NOT_CONFIGURED); } if (this.getTableStorageUri() == null) { throw new IllegalArgumentException(SR.TABLE_ENDPOINT_NOT_CONFIGURED); } if (this.credentials == null) { throw new IllegalArgumentException(SR.MISSING_CREDENTIALS); } return new CloudAnalyticsClient(this.getBlobStorageUri(), this.getTableStorageUri(), this.getCredentials()); }
CloudBlockBlob v2Blob = this.container.getBlockBlobReference("v2Blob"); v2Blob.uploadText(v2Entry); Iterator<LogRecord> v2Iterator = CloudAnalyticsClient.parseLogBlob(v2Blob).iterator(); try { v2Iterator.next(); CloudBlockBlob nonLogDataBlob = this.container.getBlockBlobReference("nonLogBlob"); nonLogDataBlob.uploadText(nonLogData); Iterator<LogRecord> nonLogDataIterator = CloudAnalyticsClient.parseLogBlob(nonLogDataBlob).iterator(); try { nonLogDataIterator.next(); nullBlobIterator.add(nullBlob2); nullBlobIterator.add(nullBlob3); Iterator<LogRecord> nullLogIterator = CloudAnalyticsClient.parseLogBlobs(nullBlobIterator).iterator(); try { nullLogIterator.next(); Iterator<LogRecord> emptyIterator = CloudAnalyticsClient.parseLogBlobs(new ArrayList<ListBlobItem>()).iterator(); assertFalse(emptyIterator.hasNext()); emptyIterator.next(); CloudAnalyticsClient.parseLogBlobs(null); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "The argument must not be null or an empty string. Argument name: logBlobs.");
CloudBlockBlob blob = this.container.getBlockBlobReference("blob1"); blob.uploadText(logText); Iterator<LogRecord> iterator = CloudAnalyticsClient.parseLogBlob(blob).iterator();
/** * Returns an enumerable collection of log records, retrieved lazily. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @return * An enumerable collection of objects that implement <code>ListBlobItem</code> and are retrieved lazily. * @throws URISyntaxException * @throws StorageException */ public Iterable<LogRecord> listLogRecords(StorageService service) throws URISyntaxException, StorageException { return this .listLogRecords(service, null /* startTime */, null /* endTime */, null /* options */, null /* operationContext */); }
/** * Returns an enumerable collection of log records, retrieved lazily. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @param startTime * A <code>java.util.Date</code> object representing the start of the time range for which logs should * be retrieved. * @param endTime * A <code>java.util.Date</code> object representing the end of the time range for which logs should * be retrieved. * @param options * A {@link BlobRequestOptions} object that specifies additional options for the request. * @param operationContext * An {@link OperationContext} object that represents the context for the current operation. * @return * An enumerable collection of objects that implement {@link ListBlobItem} and are retrieved lazily. * @throws StorageException * @throws URISyntaxException */ public Iterable<LogRecord> listLogRecords(StorageService service, Date startTime, Date endTime, BlobRequestOptions options, OperationContext operationContext) throws StorageException, URISyntaxException { Utility.assertNotNull("service", service); EnumSet<LoggingOperations> operations = EnumSet.allOf(LoggingOperations.class); EnumSet<BlobListingDetails> metadataDetails = EnumSet.noneOf(BlobListingDetails.class); Iterator<ListBlobItem> blobIterator = new LogBlobIterable(this.getLogDirectory(service), startTime, endTime, operations, metadataDetails, options, operationContext).iterator(); return new LogRecordIterable(blobIterator); }
/** * Creates a new Analytics service client. * * @return An analytics client object that uses the Blob and Table service endpoints. */ public CloudAnalyticsClient createCloudAnalyticsClient() { if (this.getBlobStorageUri() == null) { throw new IllegalArgumentException(SR.BLOB_ENDPOINT_NOT_CONFIGURED); } if (this.getTableStorageUri() == null) { throw new IllegalArgumentException(SR.TABLE_ENDPOINT_NOT_CONFIGURED); } if (this.credentials == null) { throw new IllegalArgumentException(SR.MISSING_CREDENTIALS); } return new CloudAnalyticsClient(this.getBlobStorageUri(), this.getTableStorageUri(), this.getCredentials()); }
/** * Returns an enumerable collection of log blobs, retrieved lazily. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @return * An enumerable collection of objects that implement <code>ListBlobItem</code> and are retrieved lazily. * @throws URISyntaxException * @throws StorageException */ public Iterable<ListBlobItem> listLogBlobs(StorageService service) throws URISyntaxException, StorageException { return this.listLogBlobs(service, null /* startTime */, null /* endTime */, null /* operations */, null /* details */, null /* options */, null /* operationContext */); }
/** * Validate Log Parser with prod data * * @throws ParseException * @throws URISyntaxException * @throws StorageException * @throws IOException * @throws InterruptedException */ @Test public void testCloudAnalyticsClientParseProdLogs() throws ParseException, URISyntaxException, StorageException, IOException { Calendar startTime = new GregorianCalendar(); startTime.add(GregorianCalendar.HOUR_OF_DAY, -2); Iterator<LogRecord> logRecordsIterator = (this.client.listLogRecords(StorageService.BLOB, startTime.getTime(), null, null, null)).iterator(); while (logRecordsIterator.hasNext()) { // Makes sure there's no exceptions thrown and that no records are null. // Primarily a sanity check. LogRecord rec = logRecordsIterator.next(); System.out.println(rec.getRequestUrl()); assertNotNull(rec); } }
/** * Gets the minute metrics table for a specific storage service. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @return * The {@link CloudTable} object for the storage service. * @throws URISyntaxException * @throws StorageException */ public CloudTable getMinuteMetricsTable(StorageService service) throws URISyntaxException, StorageException { return this.getMinuteMetricsTable(service, null); }
/** * Gets the hour metrics table for a specific storage service. * * @param service * A {@link StorageService} enumeration value that indicates which storage service to use. * @return * The {@link CloudTable} object for the storage service. * @throws URISyntaxException * @throws StorageException */ public CloudTable getHourMetricsTable(StorageService service) throws URISyntaxException, StorageException { return this.getHourMetricsTable(service, null); }
return new LogBlobIterable(this.getLogDirectory(service), startTime, endTime, operations, metadataDetails, options, operationContext);
/** * List Logs with well defined time range * * @throws URISyntaxException * @throws StorageException * @throws IOException * @throws InterruptedException */ @Test public void testCloudAnalyticsClientListLogsStartEndTime() throws URISyntaxException, StorageException, IOException { this.container.create(); this.client.LogContainer = this.container.getName(); int numBlobs = 72; Calendar now = new GregorianCalendar(); now.add(GregorianCalendar.DAY_OF_MONTH, -3); List<String> blobNames = AnalyticsTestHelper.CreateLogs(this.container, StorageService.BLOB, 72, now, Granularity.HOUR); assertEquals(numBlobs, blobNames.size()); Calendar start = new GregorianCalendar(); start.add(GregorianCalendar.DAY_OF_MONTH, -2); Calendar end = new GregorianCalendar(); end.add(GregorianCalendar.DAY_OF_MONTH, -1); for (ListBlobItem blob : this.client.listLogBlobs(StorageService.BLOB, start.getTime(), end.getTime(), null, null, null, null)) { assertEquals(CloudBlockBlob.class, blob.getClass()); assertTrue(blobNames.remove(((CloudBlockBlob) blob).getName())); } assertTrue(blobNames.size() == 48); }
return new LogBlobIterable(this.getLogDirectory(service), startTime, endTime, operations, metadataDetails, options, operationContext);
/** * List Logs with open ended time range * * @throws URISyntaxException * @throws StorageException * @throws IOException * @throws InterruptedException */ @Test public void testCloudAnalyticsClientListLogsStartTime() throws URISyntaxException, StorageException, IOException { this.container.create(); this.client.LogContainer = this.container.getName(); int numBlobs = 48; Calendar now = new GregorianCalendar(); now.add(GregorianCalendar.DAY_OF_MONTH, -2); List<String> blobNames = AnalyticsTestHelper.CreateLogs(this.container, StorageService.BLOB, 48, now, Granularity.HOUR); assertEquals(numBlobs, blobNames.size()); Calendar start = new GregorianCalendar(); start.add(GregorianCalendar.DAY_OF_MONTH, -1); for (ListBlobItem blob : this.client.listLogBlobs(StorageService.BLOB, start.getTime(), null, null, null, null, null)) { assertEquals(CloudBlockBlob.class, blob.getClass()); assertTrue(blobNames.remove(((CloudBlockBlob) blob).getName())); } assertTrue(blobNames.size() == 24); }