/** {@inheritDoc} */ @Override public boolean isSecurityEnabled() throws IOException { return mSystemTable.getSecurityVersion().compareTo(Versions.MIN_SECURITY_VERSION) >= 0; }
/** * Computes the effective ProtocolVersion from a layout version string. * * <p> Normalizes fiji-1.0 into layout-1.0.0 </p> * * @param version Layout version string. * @return the effective layout ProtocolVersion. */ private static ProtocolVersion computeLayoutVersion(String version) { final ProtocolVersion pversion = ProtocolVersion.parse(version); if (Objects.equal(pversion, Versions.LAYOUT_FIJI_1_0_0_DEPRECATED)) { // Deprecated "fiji-1.0" is compatible with "layout-1.0.0" return Versions.LAYOUT_1_0_0; } else { return pversion; } }
return clientVersion.getProtocolName().equals(clusterVersion.getProtocolName()) && clientVersion.getMajorVersion() >= clusterVersion.getMajorVersion();
/** {@inheritDoc} */ @Override public boolean equals(Object other) { if (null == other) { return false; } else if (this == other) { return true; } else if (!(other instanceof ProtocolVersion)) { return false; } ProtocolVersion otherVer = (ProtocolVersion) other; if (!checkEquality(mProtocol, otherVer.mProtocol)) { return false; } return getMajorVersion() == otherVer.getMajorVersion() && getMinorVersion() == otherVer.getMinorVersion() && getRevision() == otherVer.getRevision(); }
/** {@inheritDoc} */ @Override public int compareTo(ProtocolVersion other) { if (null == mProtocol && null != other.mProtocol) { // null protocol sorts ahead of any alphabetic protocol. return -1; } else if (mProtocol != null) { if (null == other.mProtocol) { return 1; // they sort as 'less than' us since their protocol name is null. } int protoCmp = mProtocol.compareTo(other.mProtocol); if (0 != protoCmp) { return protoCmp; } } int majCmp = Integer.valueOf(getMajorVersion()).compareTo(other.getMajorVersion()); if (0 != majCmp) { return majCmp; } int minCmp = Integer.valueOf(getMinorVersion()).compareTo(other.getMinorVersion()); if (0 != minCmp) { return minCmp; } int revCmp = Integer.valueOf(getRevision()).compareTo(other.getRevision()); return revCmp; }
final ProtocolVersion layoutVersion = ProtocolVersion.parse(layout.getVersion()); final ProtocolVersion systemVersion = getSystemTable().getDataVersion(); if ((layoutVersion.compareTo(Versions.LAYOUT_VALIDATION_VERSION) >= 0) && (systemVersion.compareTo(Versions.MIN_SYS_VER_FOR_LAYOUT_VALIDATION) < 0)) { throw new InvalidLayoutException( String.format("Layout version: %s not supported by system version: %s",
final ProtocolVersion importVersion = ProtocolVersion.parse(mDesc.getVersion()); if (!IMPORT_PROTOCOL_NAME.equals(importVersion.getProtocolName())) { throw new InvalidTableImportDescriptorException( String.format("Invalid version protocol: '%s'. Expected: '%s'.", importVersion.getProtocolName(), IMPORT_PROTOCOL_NAME)); if (MAX_IMPORT_VER.compareTo(importVersion) < 0) { throw new InvalidTableImportDescriptorException("The maximum import version we support is " + MAX_IMPORT_VER + "; this import requires " + importVersion); } else if (MIN_IMPORT_VER.compareTo(importVersion) > 0) { throw new InvalidTableImportDescriptorException("The minimum import version we support is " + MIN_IMPORT_VER + "; this import requires " + importVersion);
if (!Objects.equal(LAYOUT_PROTOCOL_NAME, mLayoutVersion.getProtocolName())) { final String exceptionMessage; if (Objects.equal( Versions.LAYOUT_FIJI_1_0_0_DEPRECATED.getProtocolName(), mLayoutVersion.getProtocolName())) { + " but received version '%s'. You should specify a layout version protocol" + " as '%s-x.y', not '%s-x.y'.", Versions.LAYOUT_FIJI_1_0_0_DEPRECATED.getProtocolName(), Versions.LAYOUT_FIJI_1_0_0_DEPRECATED, mLayoutVersion, LAYOUT_PROTOCOL_NAME, Versions.LAYOUT_FIJI_1_0_0_DEPRECATED.getProtocolName()); } else { exceptionMessage = String.format("Invalid version protocol: '%s'. Expected '%s'.", mLayoutVersion.getProtocolName(), LAYOUT_PROTOCOL_NAME); if (Versions.MAX_LAYOUT_VERSION.compareTo(mLayoutVersion) < 0) { throw new InvalidLayoutException("The maximum layout version we support is " + Versions.MAX_LAYOUT_VERSION + "; this layout requires " + mLayoutVersion); } else if (Versions.MIN_LAYOUT_VERSION.compareTo(mLayoutVersion) > 0) { throw new InvalidLayoutException("The minimum layout version we support is " + Versions.MIN_LAYOUT_VERSION + "; this layout requires " + mLayoutVersion); if (Versions.BLOCK_SIZE_LAYOUT_VERSION.compareTo(mLayoutVersion) > 0) { if (mDesc.getMaxFilesize() != null) { + Versions.BLOCK_SIZE_LAYOUT_VERSION.toString());
Preconditions.checkArgument(nonFlagArgs.isEmpty(), "Incorrect number of arguments for \"get-version\"."); String version = mTable.getDataVersion().toString(); getPrintStream().println("Fiji data version = " + version); return SUCCESS; Preconditions.checkArgument(nonFlagArgs.size() == 1, "Incorrect number of arguments for \"put-version <version>\"."); ProtocolVersion version = ProtocolVersion.parse(nonFlagArgs.get(0)); if (isInteractive()) { if (yesNoPrompt("Changing the version information of a system table may cause "
/** {@inheritDoc} */ @Override public synchronized void setDataVersion(ProtocolVersion version) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot set data version in SystemTable instance in state %s.", state); putValue(KEY_DATA_VERSION, Bytes.toBytes(version.toString())); }
LOG.debug("Metadata backup data version: " + backup.getLayoutVersion()); LOG.debug("Current data version: " + curDataVersion); if (!curDataVersion.equals(ProtocolVersion.parse(backup.getLayoutVersion()))) { throw new IOException(String.format( "Cannot restore: backup layout version '%s' does not match Fiji instance version '%s'.",
return new ProtocolVersion(verString, proto, major, minor, rev);
final ProtocolVersion layoutVersion = ProtocolVersion.parse(layout.getVersion()); final ProtocolVersion systemVersion = getSystemTable().getDataVersion(); if ((layoutVersion.compareTo(Versions.LAYOUT_VALIDATION_VERSION) >= 0) && (systemVersion.compareTo(Versions.MIN_SYS_VER_FOR_LAYOUT_VALIDATION) < 0)) { throw new InvalidLayoutException( String.format("Layout version: %s not supported by system version: %s",
/** {@inheritDoc} */ @Override public synchronized void setDataVersion(ProtocolVersion version) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot set data version in SystemTable instance in state %s.", state); putValue(KEY_DATA_VERSION, Bytes.toBytes(version.toString())); }
final ProtocolVersion layoutVersion = ProtocolVersion.parse(tableLayoutDesc.getVersion()); if (Versions.LAYOUT_VALIDATION_VERSION.compareTo(layoutVersion) > 0) { throw new InvalidLayoutException("Schema validation is available from " + Versions.LAYOUT_VALIDATION_VERSION + " and up; this layout is " + layoutVersion);
/** {@inheritDoc} */ @Override public boolean isSecurityEnabled() throws IOException { return mSystemTable.getSecurityVersion().compareTo(Versions.MIN_SECURITY_VERSION) >= 0; }
/** {@inheritDoc} */ @Override public synchronized ProtocolVersion getSecurityVersion() throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot get security version from SystemTable instance in state %s.", state); byte[] result = getValue(SECURITY_PROTOCOL_VERSION); return result == null ? Versions.UNINSTALLED_SECURITY_VERSION : ProtocolVersion.parse(Bytes.toString(result)); }
/** {@inheritDoc} */ @Override public synchronized void setSecurityVersion(ProtocolVersion version) throws IOException { Preconditions.checkNotNull(version); final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot set security version in SystemTable instance in state %s.", state); Fiji.Factory.open(mURI).getSecurityManager().checkCurrentGrantAccess(); putValue(SECURITY_PROTOCOL_VERSION, Bytes.toBytes(version.toString())); }
/** {@inheritDoc} */ @Override public void deleteTable(String tableName) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot delete table in Fiji instance %s in state %s.", this, state); if (mSystemVersion.compareTo(Versions.SYSTEM_2_0) < 0) { deleteTableSystem_1_0(tableName); } else if (mSystemVersion.compareTo(Versions.SYSTEM_2_0) == 0) { deleteTableSystem_2_0(tableName); } else { throw new InternalFijiError(String.format("Unknown System version %s.", mSystemVersion)); } }