Options options = AccumuloIndexAgeDisplay.buildOptions(); CommandLineParser parser = new BasicParser(); CommandLine cmd; zooKeepers = cmd.getOptionValue("z"); } else { usage(); usage(); usage(); usage(); usage(); } else { password = getPasswordFromConsole(); bucket = getBucketArray(cmd); } else { bucket = new Integer[0]; AccumuloIndexAgeDisplay aiad = new AccumuloIndexAgeDisplay(instance, tableName, columns, userName, password, bucket); aiad.extractDataFromAccumulo(); aiad.logAgeSummary(); aiad.createAccumuloShellScript(fileName);
public AccumuloIndexAgeDisplay(Instance instance, String tableName, String columns, String userName, PasswordToken password, Integer[] buckets) throws AccumuloException, AccumuloSecurityException { this.tableName = tableName; setColumns(columns); this.userName = userName; setBuckets(buckets); conn = instance.getConnector(userName, password); }
/** * Set the buckets to use to sort the accumulo data. A row of data should be in the oldest bucket possible. The buckets will be reversed sorted. If an null * or empty list is passed in it will be ignored. Entries less than two will be ignored. * * @param unsorted * - The int array that holds the day buckets */ public void setBuckets(Integer[] unsorted) { if ((unsorted != null) && (unsorted.length > 0)) { List<Integer> tmp = sortAndReverseUnsortedBuckets(unsorted); filterBuckets(tmp); } }
/** * This method completes the setup process and was redundant in all but of the tests. * * @param bucketsToUse * - the array of buckets to use */ private void completeSetup(Integer[] bucketsToUse) { try { deleteFile(fileName); aiad = new AccumuloIndexAgeDisplay(mockInstance, tableName, columns, userName, password, bucketsToUse); aiad.extractDataFromAccumulo(); aiad.logAgeSummary(); aiad.createAccumuloShellScript(fileName); } catch (AccumuloException ae) { log.error("Accumlo exception from our mock instance."); log.error(ae.getMessage()); } catch (AccumuloSecurityException ase) { log.error("Accumulo security exception from our mock instance"); log.error(ase.getMessage()); } }
/** * A test verifying the buckets are sorted in reverse order. */ @Test public void sortBucketsInReverseOrderTest() { Assert.assertNotNull(mockInstance); try { aiad = new AccumuloIndexAgeDisplay(mockInstance, tableName, columns, userName, password, new Integer[0]); aiad.setBuckets(null); Integer[] expected = {180, 90, 60, 30, 14, 7, 2}; Integer[] actual = aiad.getBuckets(); Assert.assertArrayEquals(expected, actual); Integer[] useExpectedWithTooSmallNumber = {1, 2, 3, 4, 5}; expected = new Integer[] {5, 4, 3, 2}; aiad.setBuckets(useExpectedWithTooSmallNumber); actual = aiad.getBuckets(); Assert.assertArrayEquals(expected, actual); } catch (AccumuloException ae) { log.error("Accumlo exception from our mock instance."); log.error(ae.getMessage()); } catch (AccumuloSecurityException ase) { log.error("Accumulo security exception from our mock instance"); log.error(ase.getMessage()); } }
/** * A test using the assorted data, 2 - 31 days old, using one bucket of three days. So all day older than three days should have a delete statement. */ @Test public void assortedDataIntoThreeDayBucketLogOutputTest() { // Should identify data more than three days old in the log and deletion script loadAssortedData(); completeSetup(new Integer[] {3}); String expectedLogSummary = getAssortedDataThreeDaySimulatedLogOutput(); String actualLogSummary = aiad.logAgeSummary(); Assert.assertEquals(expectedLogSummary, actualLogSummary); }
Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(userName); scanner = conn.createScanner(tableName, userAuthorizations); scanner = addColumnsToScanner(scanner); Range range = new Range(); scanner.setRange(range); long rowAge = entry.getKey().getTimestamp(); if (rowAge < mostRecent) { // ** ignore data less than the newest bucket Text deleteCommand = createDeleteCmd(entry); int bucketIndex = 0;
/** * A test with data with a timestamp one hour ago. No data should be identified as being deleteable */ @Test public void oneHourOldDataIntoDefaultBucketLogOutputTest() { // All the data is "new" so none should be ready to be aged-off loadOneHourData(); completeSetup(new Integer[0]); String expectedLogSummary = getOneHourSimulatedLogOutput(); String actualLogSummary = aiad.logAgeSummary(); Assert.assertEquals(expectedLogSummary, actualLogSummary); }
/** * A test that has an assorted of rowws with different timestamps */ @Test public void assortedDataIntoDefaultBucketLogOutputTest() { // The data entered into accumulo: 2 - one day old, 2 two days old, two , 2 eight days old, 2 fifteen days old // and 2 thirty one days old. The last eight should be removed by the default buckets loadAssortedData(); completeSetup(new Integer[0]); String expectedLogSummary = getAssortedSimulatedLogOutput(); String actualLogSummary = aiad.logAgeSummary(); Assert.assertEquals(expectedLogSummary, actualLogSummary); }