@Test public void noRelativePaths() throws Exception { VolumeManager fs = createMock(VolumeManager.class); AccumuloClient c = createMock(AccumuloClient.class); expect(fs.exists(anyObject())).andReturn(true).anyTimes(); SortedMap<Key,Value> map = new TreeMap<>(); map.put(new Key("1<", "file", "hdfs: new Value()); map.put(new Key("1<", "file", "hdfs: new Value()); map.put(new Key("1<", "file", "file: new Value()); map.put(new Key("1<", "file", "file: new Value()); List<Mutation> results = new ArrayList<>(); setupMocks(c, fs, map, results); assertFalse("Invalid Relative path check", Upgrader9to10.checkForRelativePaths(c, fs, tableName, volumeUpgrade)); assertTrue(results.isEmpty()); }
public static boolean checkForRelativePaths(AccumuloClient client, VolumeManager fs, String tableName, String upgradeProperty) { boolean hasRelatives = false; try (Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY)) { log.info("Looking for relative paths in {}", tableName); scanner.fetchColumnFamily(DataFileColumnFamily.NAME); for (Entry<Key,Value> entry : scanner) { Key key = entry.getKey(); String metaEntry = key.getColumnQualifier().toString(); if (!metaEntry.contains(":")) { hasRelatives = true; if (upgradeProperty == null || upgradeProperty.isBlank()) { throw new IllegalArgumentException( "Missing required property " + Property.INSTANCE_VOLUMES_UPGRADE_RELATIVE.getKey()); } Path relPath = resolveRelativePath(metaEntry, key); Path absPath = new Path(upgradeProperty, relPath); if (!fs.exists(absPath)) { throw new IllegalArgumentException("Tablet file " + relPath + " not found at " + absPath + " using volume: " + upgradeProperty); } } } } catch (TableNotFoundException e) { throw new IllegalStateException(e); } catch (IOException e) { throw new UncheckedIOException(e); } return hasRelatives; }
Upgrader9to10 implements Upgrader { public static boolean checkForRelativePaths(AccumuloClient client, VolumeManager fs, String tableName, String upgradeProperty) { boolean hasRelatives = false; try (Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY)) { log.info("Looking for relative paths in {}", tableName); scanner.fetchColumnFamily(DataFileColumnFamily.NAME); for (Entry<Key,Value> entry : scanner) { Key key = entry.getKey(); String metaEntry = key.getColumnQualifier().toString(); if (!metaEntry.contains(":")) { hasRelatives = true; if (upgradeProperty == null || upgradeProperty.isBlank()) { throw new IllegalArgumentException( "Missing required property " + Property.INSTANCE_VOLUMES_UPGRADE_RELATIVE.getKey()); } Path relPath = resolveRelativePath(metaEntry, key); Path absPath = new Path(upgradeProperty, relPath); if (!fs.exists(absPath)) { throw new IllegalArgumentException("Tablet file " + relPath + " not found at " + absPath + " using volume: " + upgradeProperty); } } } } catch (TableNotFoundException e) { throw new IllegalStateException(e); } catch (IOException e) { throw new UncheckedIOException(e); } return hasRelatives; } }
Upgrader9to10 implements Upgrader { public static boolean checkForRelativePaths(AccumuloClient client, VolumeManager fs, String tableName, String upgradeProperty) { boolean hasRelatives = false; try (Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY)) { log.info("Looking for relative paths in {}", tableName); scanner.fetchColumnFamily(DataFileColumnFamily.NAME); for (Entry<Key,Value> entry : scanner) { Key key = entry.getKey(); String metaEntry = key.getColumnQualifier().toString(); if (!metaEntry.contains(":")) { hasRelatives = true; if (upgradeProperty == null || upgradeProperty.isBlank()) { throw new IllegalArgumentException( "Missing required property " + Property.INSTANCE_VOLUMES_UPGRADE_RELATIVE.getKey()); } Path relPath = resolveRelativePath(metaEntry, key); Path absPath = new Path(upgradeProperty, relPath); if (!fs.exists(absPath)) { throw new IllegalArgumentException("Tablet file " + relPath + " not found at " + absPath + " using volume: " + upgradeProperty); } } } } catch (TableNotFoundException e) { throw new IllegalStateException(e); } catch (IOException e) { throw new UncheckedIOException(e); } return hasRelatives; }  }
Upgrader9to10 implements Upgrader { public static boolean checkForRelativePaths(AccumuloClient client, VolumeManager fs, String tableName, String upgradeProperty) { boolean hasRelatives = false; try (Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY)) { log.info("Looking for relative paths in {}", tableName); scanner.fetchColumnFamily(DataFileColumnFamily.NAME); for (Entry<Key,Value> entry : scanner) { Key key = entry.getKey(); String metaEntry = key.getColumnQualifier().toString(); if (!metaEntry.contains(":")) { hasRelatives = true; if (upgradeProperty == null || upgradeProperty.isBlank()) { throw new IllegalArgumentException( "Missing required property " + Property.INSTANCE_VOLUMES_UPGRADE_RELATIVE.getKey()); } Path relPath = resolveRelativePath(metaEntry, key); Path absPath = new Path(upgradeProperty, relPath); if (!fs.exists(absPath)) { throw new IllegalArgumentException("Tablet file " + relPath + " not found at " + absPath + " using volume: " + upgradeProperty); } } } } catch (TableNotFoundException e) { throw new IllegalStateException(e); } catch (IOException e) { throw new UncheckedIOException(e); } return hasRelatives; }  @Override void upgradeZookeeper(ServerContext ctx); @Override void upgradeRoot(ServerContext ctx); @Override void upgradeMetadata(ServerContext ctx); void upgradeFileDeletes(ServerContext ctx, Ample.DataLevel level); void upgradeDirColumns(ServerContext ctx, Ample.DataLevel level); static String upgradeDirColumn(String dir); static void upgradeRelativePaths(ServerContext ctx, Ample.DataLevel level); static void replaceRelativePaths(AccumuloClient c, VolumeManager fs, String tableName,
      String upgradeProperty); static boolean checkForRelativePaths(AccumuloClient client, VolumeManager fs,
      String tableName, String upgradeProperty); }
Upgrader9to10 implements Upgrader { public static boolean checkForRelativePaths(AccumuloClient client, VolumeManager fs, String tableName, String upgradeProperty) { boolean hasRelatives = false; try (Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY)) { log.info("Looking for relative paths in {}", tableName); scanner.fetchColumnFamily(DataFileColumnFamily.NAME); for (Entry<Key,Value> entry : scanner) { Key key = entry.getKey(); String metaEntry = key.getColumnQualifier().toString(); if (!metaEntry.contains(":")) { hasRelatives = true; if (upgradeProperty == null || upgradeProperty.isBlank()) { throw new IllegalArgumentException( "Missing required property " + Property.INSTANCE_VOLUMES_UPGRADE_RELATIVE.getKey()); } Path relPath = resolveRelativePath(metaEntry, key); Path absPath = new Path(upgradeProperty, relPath); if (!fs.exists(absPath)) { throw new IllegalArgumentException("Tablet file " + relPath + " not found at " + absPath + " using volume: " + upgradeProperty); } } } } catch (TableNotFoundException e) { throw new IllegalStateException(e); } catch (IOException e) { throw new UncheckedIOException(e); } return hasRelatives; }  @Override void upgradeZookeeper(ServerContext ctx); @Override void upgradeRoot(ServerContext ctx); @Override void upgradeMetadata(ServerContext ctx); void upgradeFileDeletes(ServerContext ctx, Ample.DataLevel level); void upgradeDirColumns(ServerContext ctx, Ample.DataLevel level); static String upgradeDirColumn(String dir); static void upgradeRelativePaths(ServerContext ctx, Ample.DataLevel level); static void replaceRelativePaths(AccumuloClient c, VolumeManager fs, String tableName,
      String upgradeProperty); static boolean checkForRelativePaths(AccumuloClient client, VolumeManager fs,
      String tableName, String upgradeProperty); static final String ZROOT_TABLET_LOCATION; static final String ZROOT_TABLET_FUTURE_LOCATION; static final String ZROOT_TABLET_LAST_LOCATION; static final String ZROOT_TABLET_WALOGS; static final String ZROOT_TABLET_CURRENT_LOGS; static final String ZROOT_TABLET_PATH; static final Value UPGRADED; static final String OLD_DELETE_PREFIX; static final long CANDIDATE_BATCH_SIZE; }