|
@@ -27,9 +27,7 @@ import org.apache.hadoop.ipc.ProtobufRpcEngine;
|
|
|
import org.apache.hadoop.ozone.OzoneAcl;
|
|
|
import org.apache.hadoop.ozone.OzoneConfigKeys;
|
|
|
import org.apache.hadoop.ozone.om.exceptions.OMException;
|
|
|
-import org.apache.hadoop.ozone.om.helpers.OmDeleteVolumeResponse;
|
|
|
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
|
|
|
-import org.apache.hadoop.ozone.om.helpers.OmVolumeOwnerChangeResponse;
|
|
|
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo;
|
|
|
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeList;
|
|
|
import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer;
|
|
@@ -57,9 +55,9 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
|
|
|
private final OMMetadataManager metadataManager;
|
|
|
private final int maxUserVolumeCount;
|
|
|
- private final boolean isRatisEnabled;
|
|
|
private final boolean aclEnabled;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* Constructor.
|
|
|
* @param conf - Ozone configuration.
|
|
@@ -70,9 +68,6 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
this.metadataManager = metadataManager;
|
|
|
this.maxUserVolumeCount = conf.getInt(OZONE_OM_USER_MAX_VOLUME,
|
|
|
OZONE_OM_USER_MAX_VOLUME_DEFAULT);
|
|
|
- isRatisEnabled = conf.getBoolean(
|
|
|
- OMConfigKeys.OZONE_OM_RATIS_ENABLE_KEY,
|
|
|
- OMConfigKeys.OZONE_OM_RATIS_ENABLE_DEFAULT);
|
|
|
aclEnabled = conf.getBoolean(OzoneConfigKeys.OZONE_ACL_ENABLED,
|
|
|
OzoneConfigKeys.OZONE_ACL_ENABLED_DEFAULT);
|
|
|
}
|
|
@@ -125,10 +120,9 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
/**
|
|
|
* Creates a volume.
|
|
|
* @param omVolumeArgs - OmVolumeArgs.
|
|
|
- * @return VolumeList
|
|
|
*/
|
|
|
@Override
|
|
|
- public VolumeList createVolume(OmVolumeArgs omVolumeArgs) throws IOException {
|
|
|
+ public void createVolume(OmVolumeArgs omVolumeArgs) throws IOException {
|
|
|
Preconditions.checkNotNull(omVolumeArgs);
|
|
|
|
|
|
boolean acquiredUserLock = false;
|
|
@@ -156,13 +150,12 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
// Set creation time
|
|
|
omVolumeArgs.setCreationTime(System.currentTimeMillis());
|
|
|
|
|
|
- if (!isRatisEnabled) {
|
|
|
- createVolumeCommitToDB(omVolumeArgs, volumeList, dbVolumeKey,
|
|
|
+
|
|
|
+ createVolumeCommitToDB(omVolumeArgs, volumeList, dbVolumeKey,
|
|
|
dbUserKey);
|
|
|
- }
|
|
|
+
|
|
|
LOG.debug("created volume:{} user:{}", omVolumeArgs.getVolume(),
|
|
|
omVolumeArgs.getOwnerName());
|
|
|
- return volumeList;
|
|
|
} catch (IOException ex) {
|
|
|
if (!(ex instanceof OMException)) {
|
|
|
LOG.error("Volume creation failed for user:{} volume:{}",
|
|
@@ -179,22 +172,6 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public void applyCreateVolume(OmVolumeArgs omVolumeArgs,
|
|
|
- VolumeList volumeList) throws IOException {
|
|
|
- // Do we need to hold lock in apply Transactions requests?
|
|
|
- String dbVolumeKey = metadataManager.getVolumeKey(omVolumeArgs.getVolume());
|
|
|
- String dbUserKey = metadataManager.getUserKey(omVolumeArgs.getOwnerName());
|
|
|
- try {
|
|
|
- createVolumeCommitToDB(omVolumeArgs, volumeList, dbVolumeKey, dbUserKey);
|
|
|
- } catch (IOException ex) {
|
|
|
- LOG.error("Volume creation failed for user:{} volume:{}",
|
|
|
- omVolumeArgs.getOwnerName(), omVolumeArgs.getVolume(), ex);
|
|
|
- throw ex;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void createVolumeCommitToDB(OmVolumeArgs omVolumeArgs,
|
|
|
VolumeList volumeList, String dbVolumeKey, String dbUserKey)
|
|
|
throws IOException {
|
|
@@ -220,7 +197,7 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
@Override
|
|
|
- public OmVolumeOwnerChangeResponse setOwner(String volume, String owner)
|
|
|
+ public void setOwner(String volume, String owner)
|
|
|
throws IOException {
|
|
|
Preconditions.checkNotNull(volume);
|
|
|
Preconditions.checkNotNull(owner);
|
|
@@ -252,12 +229,8 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
VolumeList newOwnerVolumeList = addVolumeToOwnerList(volume, newOwner);
|
|
|
|
|
|
volumeArgs.setOwnerName(owner);
|
|
|
- if (!isRatisEnabled) {
|
|
|
- setOwnerCommitToDB(oldOwnerVolumeList, newOwnerVolumeList,
|
|
|
- volumeArgs, owner);
|
|
|
- }
|
|
|
- return new OmVolumeOwnerChangeResponse(oldOwnerVolumeList,
|
|
|
- newOwnerVolumeList, volumeArgs, originalOwner);
|
|
|
+ setOwnerCommitToDB(oldOwnerVolumeList, newOwnerVolumeList,
|
|
|
+ volumeArgs, owner);
|
|
|
} catch (IOException ex) {
|
|
|
if (!(ex instanceof OMException)) {
|
|
|
LOG.error("Changing volume ownership failed for user:{} volume:{}",
|
|
@@ -272,21 +245,6 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void applySetOwner(String oldOwner, VolumeList oldOwnerVolumeList,
|
|
|
- VolumeList newOwnerVolumeList, OmVolumeArgs newOwnerVolumeArgs)
|
|
|
- throws IOException {
|
|
|
- try {
|
|
|
- setOwnerCommitToDB(oldOwnerVolumeList, newOwnerVolumeList,
|
|
|
- newOwnerVolumeArgs, oldOwner);
|
|
|
- } catch (IOException ex) {
|
|
|
- LOG.error("Changing volume ownership failed for user:{} volume:{}",
|
|
|
- newOwnerVolumeArgs.getOwnerName(), newOwnerVolumeArgs.getVolume(),
|
|
|
- ex);
|
|
|
- throw ex;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
private void setOwnerCommitToDB(VolumeList oldOwnerVolumeList,
|
|
|
VolumeList newOwnerVolumeList, OmVolumeArgs newOwnerVolumeArgs,
|
|
@@ -318,11 +276,10 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
* @param volume - Name of the volume.
|
|
|
* @param quota - Quota in bytes.
|
|
|
*
|
|
|
- * @return OmVolumeArgs
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
@Override
|
|
|
- public OmVolumeArgs setQuota(String volume, long quota) throws IOException {
|
|
|
+ public void setQuota(String volume, long quota) throws IOException {
|
|
|
Preconditions.checkNotNull(volume);
|
|
|
metadataManager.getLock().acquireLock(VOLUME_LOCK, volume);
|
|
|
try {
|
|
@@ -336,13 +293,9 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
|
|
|
Preconditions.checkState(volume.equals(volumeArgs.getVolume()));
|
|
|
|
|
|
-
|
|
|
volumeArgs.setQuotaInBytes(quota);
|
|
|
|
|
|
- if (!isRatisEnabled) {
|
|
|
- metadataManager.getVolumeTable().put(dbVolumeKey, volumeArgs);
|
|
|
- }
|
|
|
- return volumeArgs;
|
|
|
+ metadataManager.getVolumeTable().put(dbVolumeKey, volumeArgs);
|
|
|
} catch (IOException ex) {
|
|
|
if (!(ex instanceof OMException)) {
|
|
|
LOG.error("Changing volume quota failed for volume:{} quota:{}", volume,
|
|
@@ -354,19 +307,6 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void applySetQuota(OmVolumeArgs omVolumeArgs) throws IOException {
|
|
|
- try {
|
|
|
- String dbVolumeKey = metadataManager.getVolumeKey(
|
|
|
- omVolumeArgs.getVolume());
|
|
|
- metadataManager.getVolumeTable().put(dbVolumeKey, omVolumeArgs);
|
|
|
- } catch (IOException ex) {
|
|
|
- LOG.error("Changing volume quota failed for volume:{} quota:{}",
|
|
|
- omVolumeArgs.getVolume(), omVolumeArgs.getQuotaInBytes(), ex);
|
|
|
- throw ex;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Gets the volume information.
|
|
|
* @param volume - Volume name.
|
|
@@ -402,12 +342,10 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
* Deletes an existing empty volume.
|
|
|
*
|
|
|
* @param volume - Name of the volume.
|
|
|
- *
|
|
|
- * @return OmDeleteVolumeResponse
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
@Override
|
|
|
- public OmDeleteVolumeResponse deleteVolume(String volume) throws IOException {
|
|
|
+ public void deleteVolume(String volume) throws IOException {
|
|
|
Preconditions.checkNotNull(volume);
|
|
|
String owner = null;
|
|
|
boolean acquiredUserLock = false;
|
|
@@ -435,11 +373,8 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
VolumeList newVolumeList = delVolumeFromOwnerList(volume,
|
|
|
volumeArgs.getOwnerName());
|
|
|
|
|
|
- if (!isRatisEnabled) {
|
|
|
- deleteVolumeCommitToDB(newVolumeList,
|
|
|
- volume, owner);
|
|
|
- }
|
|
|
- return new OmDeleteVolumeResponse(volume, owner, newVolumeList);
|
|
|
+
|
|
|
+ deleteVolumeCommitToDB(newVolumeList, volume, owner);
|
|
|
} catch (IOException ex) {
|
|
|
if (!(ex instanceof OMException)) {
|
|
|
LOG.error("Delete volume failed for volume:{}", volume, ex);
|
|
@@ -454,17 +389,6 @@ public class VolumeManagerImpl implements VolumeManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void applyDeleteVolume(String volume, String owner,
|
|
|
- VolumeList newVolumeList) throws IOException {
|
|
|
- try {
|
|
|
- deleteVolumeCommitToDB(newVolumeList, volume, owner);
|
|
|
- } catch (IOException ex) {
|
|
|
- LOG.error("Delete volume failed for volume:{}", volume,
|
|
|
- ex);
|
|
|
- throw ex;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
private void deleteVolumeCommitToDB(VolumeList newVolumeList,
|
|
|
String volume, String owner) throws IOException {
|