public static synchronized int getAccumuloPersistentVersion(VolumeManager fs) { // It doesn't matter which Volume is used as they should all have the data version stored return getAccumuloPersistentVersion(fs.getVolumes().iterator().next()); }
public static synchronized void updateAccumuloVersion(FileSystem fs) { try { if (getAccumuloPersistentVersion(fs) == Constants.PREV_DATA_VERSION) { fs.create(new Path(ServerConstants.getDataVersionLocation() + "/" + Constants.DATA_VERSION)); // TODO document failure mode & recovery if FS permissions cause above to work and below to fail ACCUMULO-2596 fs.delete(new Path(ServerConstants.getDataVersionLocation() + "/" + Constants.PREV_DATA_VERSION), false); } } catch (IOException e) { throw new RuntimeException("Unable to set accumulo version: an error occurred.", e); } }
private void upgradeMetadata() { if (Accumulo.getAccumuloPersistentVersion(fs) == Constants.PREV_DATA_VERSION) {
public static synchronized void updateAccumuloVersion(VolumeManager fs, int oldVersion) { for (Volume volume : fs.getVolumes()) { try { if (getAccumuloPersistentVersion(volume) == oldVersion) { log.debug("Attempting to upgrade " + volume); Path dataVersionLocation = ServerConstants.getDataVersionLocation(volume); fs.create(new Path(dataVersionLocation, Integer.toString(ServerConstants.DATA_VERSION))) .close(); // TODO document failure mode & recovery if FS permissions cause above to work and below // to fail ACCUMULO-2596 Path prevDataVersionLoc = new Path(dataVersionLocation, Integer.toString(oldVersion)); if (!fs.delete(prevDataVersionLoc)) { throw new RuntimeException("Could not delete previous data version location (" + prevDataVersionLoc + ") for " + volume); } } } catch (IOException e) { throw new RuntimeException("Unable to set accumulo version: an error occurred.", e); } } }
public static synchronized int getAccumuloPersistentVersion(Volume v) { Path path = ServerConstants.getDataVersionLocation(v); return getAccumuloPersistentVersion(v.getFileSystem(), path); }
final int accumuloPersistentVersion = Accumulo.getAccumuloPersistentVersion(fs); if (Accumulo.persistentVersionNeedsUpgrade(accumuloPersistentVersion)) {
currentIid = ZooUtil.getInstanceIDFromHdfs(path, SiteConfiguration.getInstance()); Path vpath = new Path(baseDir, VERSION_DIR); currentVersion = Accumulo.getAccumuloPersistentVersion( vpath.getFileSystem(CachedConfiguration.getInstance()), vpath); } catch (Exception e) {
private static void addVolumes(VolumeManager fs) throws IOException { String[] volumeURIs = VolumeConfiguration.getVolumeUris(SiteConfiguration.getInstance()); HashSet<String> initializedDirs = new HashSet<>(); initializedDirs.addAll(Arrays.asList(ServerConstants.checkBaseUris(volumeURIs, true))); HashSet<String> uinitializedDirs = new HashSet<>(); uinitializedDirs.addAll(Arrays.asList(volumeURIs)); uinitializedDirs.removeAll(initializedDirs); Path aBasePath = new Path(initializedDirs.iterator().next()); Path iidPath = new Path(aBasePath, ServerConstants.INSTANCE_ID_DIR); Path versionPath = new Path(aBasePath, ServerConstants.VERSION_DIR); UUID uuid = UUID .fromString(ZooUtil.getInstanceIDFromHdfs(iidPath, SiteConfiguration.getInstance())); for (Pair<Path,Path> replacementVolume : ServerConstants.getVolumeReplacements()) { if (aBasePath.equals(replacementVolume.getFirst())) log.error(aBasePath + " is set to be replaced in " + Property.INSTANCE_VOLUMES_REPLACEMENTS + " and should not appear in " + Property.INSTANCE_VOLUMES + ". It is highly recommended that this property be removed as data" + " could still be written to this volume."); } if (ServerConstants.DATA_VERSION != Accumulo.getAccumuloPersistentVersion( versionPath.getFileSystem(CachedConfiguration.getInstance()), versionPath)) { throw new IOException("Accumulo " + Constants.VERSION + " cannot initialize data version " + Accumulo.getAccumuloPersistentVersion(fs)); } initDirs(fs, uuid, uinitializedDirs.toArray(new String[uinitializedDirs.size()]), true); }
int dataVersion = Accumulo.getAccumuloPersistentVersion(fs); log.info("Data Version " + dataVersion); Accumulo.waitForZookeeperAndHdfs(fs);
if (Accumulo.getAccumuloPersistentVersion(fs) == Constants.PREV_DATA_VERSION) {
int dataVersion = Accumulo.getAccumuloPersistentVersion(fs); log.info("Data Version " + dataVersion); Accumulo.waitForZookeeperAndHdfs(fs);
private void upgradeZookeeper() { // 1.5.1 and 1.6.0 both do some state checking after obtaining the zoolock for the // monitor and before starting up. It's not tied to the data version at all (and would // introduce unnecessary complexity to try to make the master do it), but be aware // that the master is not the only thing that may alter zookeeper before starting. if (Accumulo.getAccumuloPersistentVersion(fs) == Constants.PREV_DATA_VERSION) { // This Master hasn't started Fate yet, so any outstanding transactions must be from before the upgrade. // Change to Guava's Verify once we use Guava 17. if (null != fate) { throw new IllegalStateException( "Access to Fate should not have been initialized prior to the Master transitioning to active. Please save all logs and file a bug."); } Accumulo.abortIfFateTransactions(); try { log.info("Upgrading zookeeper"); IZooReaderWriter zoo = ZooReaderWriter.getInstance(); zoo.recursiveDelete(ZooUtil.getRoot(instance) + "/loggers", NodeMissingPolicy.SKIP); zoo.recursiveDelete(ZooUtil.getRoot(instance) + "/dead/loggers", NodeMissingPolicy.SKIP); zoo.putPersistentData(ZooUtil.getRoot(instance) + Constants.ZRECOVERY, new byte[] {'0'}, NodeExistsPolicy.SKIP); for (String id : Tables.getIdToNameMap(instance).keySet()) { zoo.putPersistentData(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + id + Constants.ZTABLE_COMPACT_CANCEL_ID, "0".getBytes(UTF_8), NodeExistsPolicy.SKIP); } haveUpgradedZooKeeper = true; } catch (Exception ex) { log.fatal("Error performing upgrade", ex); System.exit(1); } } }
final int accumuloPersistentVersion = Accumulo.getAccumuloPersistentVersion(fs); if (Accumulo.persistentVersionNeedsUpgrade(accumuloPersistentVersion)) {