diff options
author | Shireesh Anjal <shireesh@gluster.com> | 2011-09-23 10:54:34 +0530 |
---|---|---|
committer | Shireesh Anjal <shireesh@gluster.com> | 2011-10-10 15:25:08 +0530 |
commit | 2babe9c17733e9c05d24b10c549469f56748df5f (patch) | |
tree | 9eae8dda4d9d9572ee01533050410114d318c1e0 /src | |
parent | a0327dce2fd70eac192f27ab296dfd319db049ca (diff) |
Introducing mechanism for version specific interface to GlusterFS
Diffstat (limited to 'src')
13 files changed, 1080 insertions, 244 deletions
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java index c1205c0e..579cc9da 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java @@ -34,6 +34,10 @@ public class TaskStatus extends Status { super(status.getCode(), status.getMessage()); } + public boolean isCommitPending() { + return getCode() == STATUS_CODE_COMMIT_PENDING; + } + public boolean isPercentageSupported() { return isPercentageSupported; } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Version.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Version.java new file mode 100644 index 00000000..887506a9 --- /dev/null +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Version.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com> + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * <http://www.gnu.org/licenses/>. + *******************************************************************************/ +package com.gluster.storage.management.core.model; + +/** + * + */ +public class Version implements Comparable<Version> { + public int major = 0; + public int minor = 0; + public int maintenance = 0; + + public Version(String version) { + String[] versionParts = version.split(".", -1); + major = Integer.valueOf(versionParts[0]); + if(versionParts.length > 1) { + minor = Integer.valueOf(versionParts[1]); + } + if(versionParts.length > 2) { + maintenance = Integer.valueOf(versionParts[2]); + } + } + + @Override + public int compareTo(Version newVer) { + if(this.major < newVer.major) { + return -1; + } else if(this.major > newVer.major) { + return 1; + } + + // major version is same + if(this.minor < newVer.minor) { + return -1; + } else if(this.minor > newVer.minor) { + return 1; + } + + // major.minor is same + if(this.maintenance < newVer.maintenance) { + return -1; + } else if(this.maintenance > newVer.maintenance) { + return 1; + } + + // major.minor.maintenance is same + return 0; + } +}
\ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java index 7d9ec340..26c244dd 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java @@ -100,4 +100,21 @@ public class StringUtil { } return output; } + + /** + * Extract value of given token from given line. It is assumed that the token, if present, will be of the following + * form: <code>token: value</code> + * + * @param line + * Line to be analyzed + * @param token + * Token whose value is to be extracted + * @return Value of the token, if present in the line + */ + public static String extractToken(String line, String token) { + if (line.contains(token)) { + return line.split(token)[1].trim(); + } + return null; + } } diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/AbstractGlusterInterface.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/AbstractGlusterInterface.java new file mode 100644 index 00000000..93db0267 --- /dev/null +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/AbstractGlusterInterface.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com> + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * <http://www.gnu.org/licenses/>. + *******************************************************************************/ +package com.gluster.storage.management.gateway.services; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.gluster.storage.management.gateway.utils.ServerUtil; + +/** + * Abstract Gluster Interface - provides functionality common across all versions of GlusterFS e.g. version check. + */ +public abstract class AbstractGlusterInterface implements GlusterInterface { + + @Autowired + protected ServerUtil serverUtil; + + @Override + public String getVersion(String serverName) { + return serverUtil.executeOnServer(serverName, "gluster --version").split("\n")[0].replaceAll("glusterfs ", "") + .replaceAll(" built.*", ""); + } +} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java index 852d7365..4bc68c5e 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java @@ -35,7 +35,6 @@ import com.gluster.storage.management.core.utils.LRUCache; import com.gluster.storage.management.gateway.data.ClusterInfo; import com.gluster.storage.management.gateway.data.PersistenceDao; import com.gluster.storage.management.gateway.data.ServerInfo; -import com.gluster.storage.management.gateway.utils.GlusterUtil; import com.gluster.storage.management.gateway.utils.ServerUtil; import com.gluster.storage.management.gateway.utils.SshUtil; @@ -51,7 +50,7 @@ public class ClusterService { private PersistenceDao<ServerInfo> serverDao; @Autowired - private GlusterUtil glusterUtil; + private GlusterServerService glusterServerService; @Autowired private SshUtil sshUtil; @@ -59,9 +58,6 @@ public class ClusterService { @Autowired private ServerUtil serverUtil; - @Autowired - private GlusterServerService glusterServerService; - private LRUCache<String, GlusterServer> onlineServerCache = new LRUCache<String, GlusterServer>(3); private static final Logger logger = Logger.getLogger(ClusterService.class); @@ -162,7 +158,7 @@ public class ClusterService { GlusterServer server = new GlusterServer(knownServer); try { - List<GlusterServer> glusterServers = glusterUtil.getGlusterServers(server); + List<GlusterServer> glusterServers = glusterServerService.getGlusterServers(server.getName()); List<ServerInfo> servers = new ArrayList<ServerInfo>(); for(GlusterServer glusterServer : glusterServers) { String serverName = glusterServer.getName(); diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java index a7a96ccd..fba64352 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java @@ -1,6 +1,4 @@ -/** - * GlusterUtil.java - * +/******************************************************************************* * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com> * This file is part of Gluster Management Console. * @@ -8,17 +6,17 @@ * modify it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * Gluster Management Console is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License * for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see * <http://www.gnu.org/licenses/>. - */ -package com.gluster.storage.management.gateway.utils; + *******************************************************************************/ +package com.gluster.storage.management.gateway.services; import java.util.ArrayList; import java.util.List; @@ -26,7 +24,7 @@ import java.util.Map; import java.util.Map.Entry; import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import com.gluster.storage.management.core.constants.CoreConstants; @@ -34,10 +32,6 @@ import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.Brick; import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.InitDiskStatusResponse; -import com.gluster.storage.management.core.model.InitDiskStatusResponse.FORMAT_STATUS; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskStatus; import com.gluster.storage.management.core.model.Volume; @@ -47,12 +41,12 @@ import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; import com.gluster.storage.management.core.utils.StringUtil; +/** + * Gluster Interface for GlusterFS version 3.2.3 + */ @Component -public class GlusterUtil { - private static final String HOSTNAME_PFX = "Hostname:"; - private static final String UUID_PFX = "Uuid:"; - private static final String STATE_PFX = "State:"; - private static final String GLUSTER_SERVER_STATUS_ONLINE = "Peer in Cluster (Connected)"; +@Lazy(value=true) +public class Gluster323InterfaceService extends AbstractGlusterInterface { private static final String VOLUME_NAME_PFX = "Volume Name:"; private static final String VOLUME_TYPE_PFX = "Type:"; @@ -68,136 +62,51 @@ public class GlusterUtil { private static final String VOLUME_TYPE_STRIPE = "Stripe"; private static final String VOLUME_TYPE_DISTRIBUTED_STRIPE = "Distributed-Stripe"; - private static final String GLUSTERD_INFO_FILE = "/etc/glusterd/glusterd.info"; - - private static final String INITIALIZE_DISK_STATUS_SCRIPT = "get_format_device_status.py"; private static final String BRICK_STATUS_SCRIPT = "get_brick_status.py"; + private static final Logger logger = Logger.getLogger(Gluster323InterfaceService.class); - private static final Logger logger = Logger.getLogger(GlusterUtil.class); - - @Autowired - private ServerUtil serverUtil; - - /** - * Extract value of given token from given line. It is assumed that the token, if present, will be of the following - * form: <code>token: value</code> - * - * @param line - * Line to be analyzed - * @param token - * Token whose value is to be extracted - * @return Value of the token, if present in the line + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#addServer(java.lang.String, java.lang.String) */ - private final String extractToken(String line, String token) { - if (line.contains(token)) { - return line.split(token)[1].trim(); - } - return null; - } - - public GlusterServer getGlusterServer(GlusterServer onlineServer, String serverName) { - List<GlusterServer> servers = getGlusterServers(onlineServer); - for (GlusterServer server : servers) { - if (server.getName().equalsIgnoreCase(serverName)) { - return server; - } - } - return null; - } - - private String getUuid(String serverName) { - return serverUtil.executeOnServer(serverName, "cat " + GLUSTERD_INFO_FILE, String.class).split("=")[1]; - } - - public List<GlusterServer> getGlusterServers(GlusterServer knownServer) { - String output = getPeerStatus(knownServer.getName()); - - knownServer.setUuid(getUuid(knownServer.getName())); - - List<GlusterServer> glusterServers = new ArrayList<GlusterServer>(); - glusterServers.add(knownServer); - - GlusterServer server = null; - boolean foundHost = false; - boolean foundUuid = false; - for (String line : output.split(CoreConstants.NEWLINE)) { - if (foundHost && foundUuid) { - // Host and UUID is found, we should look for state - String state = extractToken(line, STATE_PFX); - if (state != null) { - server.setStatus(state.contains(GLUSTER_SERVER_STATUS_ONLINE) ? SERVER_STATUS.ONLINE - : SERVER_STATUS.OFFLINE); - // Completed populating current server. Add it to the list - // and reset all related variables. - glusterServers.add(server); - - foundHost = false; - foundUuid = false; - server = null; - } - } else if (foundHost) { - // Host is found, look for UUID - String uuid = extractToken(line, UUID_PFX); - if (uuid != null) { - server.setUuid(uuid); - foundUuid = true; - } - } else { - // Look for the next host - if (server == null) { - server = new GlusterServer(); - } - String hostName = extractToken(line, HOSTNAME_PFX); - if (hostName != null) { - server.setName(hostName); - foundHost = true; - } - } - - } - return glusterServers; - } - - /** - * @param knownServer - * A known server on which the gluster command will be executed to fetch peer status - * @return Outout of the "gluster peer status" command - */ - private String getPeerStatus(String knownServer) { - return serverUtil.executeOnServer(knownServer, "gluster peer status", String.class); - } - + @Override public void addServer(String existingServer, String newServer) { serverUtil.executeOnServer(existingServer, "gluster peer probe " + newServer); // reverse peer probe to ensure that host names appear in peer status on both sides serverUtil.executeOnServer(newServer, "gluster peer probe " + existingServer); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#startVolume(java.lang.String, java.lang.String) + */ + @Override public void startVolume(String volumeName, String knownServer) { serverUtil.executeOnServer(knownServer, "gluster volume start " + volumeName); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopVolume(java.lang.String, java.lang.String) + */ + @Override public void stopVolume(String volumeName, String knownServer) { serverUtil.executeOnServer(knownServer, "gluster --mode=script volume stop " + volumeName); } - - public void logRotate(String volumeName, List<String> brickList, String knownServer) { - if (brickList.size() > 0) { - for (String brickDir : brickList) { - serverUtil.executeOnServer(knownServer, "gluster volume log rotate " + volumeName + " " + brickDir); - } - } else { - serverUtil.executeOnServer(knownServer, "gluster volume log rotate " + volumeName); - } - } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#resetOptions(java.lang.String, java.lang.String) + */ + @Override public void resetOptions(String volumeName, String knownServer) { serverUtil.executeOnServer(knownServer, "gluster volume reset " + volumeName); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#createVolume(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String) + */ + @Override public void createVolume(String knownServer, String volumeName, String volumeTypeStr, String transportTypeStr, Integer count, String bricks, String accessProtocols, String options) { + // TODO: Disable NFS if required depending on value of accessProtocols VOLUME_TYPE volType = Volume.getVolumeTypeByStr(volumeTypeStr); String volTypeArg = null; if (volType == VOLUME_TYPE.REPLICATE || volType == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { @@ -237,6 +146,10 @@ public class GlusterUtil { return command.toString(); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#createOptions(java.lang.String, java.util.Map, java.lang.String) + */ + @Override public void createOptions(String volumeName, Map<String, String> options, String knownServer) { String errors = ""; if (options != null) { @@ -258,11 +171,19 @@ public class GlusterUtil { } } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#setOption(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override public void setOption(String volumeName, String key, String value, String knownServer) { serverUtil.executeOnServer(knownServer, "gluster volume set " + volumeName + " " + key + " " + "\"" + value + "\""); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#deleteVolume(java.lang.String, java.lang.String) + */ + @Override public void deleteVolume(String volumeName, String knownServer) { serverUtil.executeOnServer(knownServer, "gluster --mode=script volume delete " + volumeName); } @@ -276,7 +197,7 @@ public class GlusterUtil { } private boolean readVolumeType(Volume volume, String line) { - String volumeType = extractToken(line, VOLUME_TYPE_PFX); + String volumeType = StringUtil.extractToken(line, VOLUME_TYPE_PFX); if (volumeType != null) { if (volumeType.equals(VOLUME_TYPE_DISTRIBUTE)) { volume.setVolumeType(VOLUME_TYPE.DISTRIBUTE); @@ -303,7 +224,7 @@ public class GlusterUtil { } private void readReplicaOrStripeCount(Volume volume, String line) { - if (extractToken(line, "x") != null) { + if (StringUtil.extractToken(line, "x") != null) { // expected formated of line is "Number of Bricks: 3 x 2 = 6" int count = Integer.parseInt(line.split("x")[1].split("=")[0].trim()); if (volume.getVolumeType() == VOLUME_TYPE.STRIPE @@ -319,7 +240,7 @@ public class GlusterUtil { } private boolean readVolumeStatus(Volume volume, String line) { - String volumeStatus = extractToken(line, VOLUME_STATUS_PFX); + String volumeStatus = StringUtil.extractToken(line, VOLUME_STATUS_PFX); if (volumeStatus != null) { volume.setStatus(volumeStatus.equals("Started") ? VOLUME_STATUS.ONLINE : VOLUME_STATUS.OFFLINE); return true; @@ -328,7 +249,7 @@ public class GlusterUtil { } private boolean readTransportType(Volume volume, String line) { - String transportType = extractToken(line, VOLUME_TRANSPORT_TYPE_PFX); + String transportType = StringUtil.extractToken(line, VOLUME_TRANSPORT_TYPE_PFX); if (transportType != null) { volume.setTransportType(transportType.equals("tcp") ? TRANSPORT_TYPE.ETHERNET : TRANSPORT_TYPE.INFINIBAND); return true; @@ -375,11 +296,11 @@ public class GlusterUtil { } private boolean readBrickGroup(String line) { - return extractToken(line, VOLUME_BRICKS_GROUP_PFX) != null; + return StringUtil.extractToken(line, VOLUME_BRICKS_GROUP_PFX) != null; } private boolean readOptionReconfigGroup(String line) { - return extractToken(line, VOLUME_OPTIONS_RECONFIG_PFX) != null; + return StringUtil.extractToken(line, VOLUME_OPTIONS_RECONFIG_PFX) != null; } private boolean readOption(Volume volume, String line) { @@ -400,10 +321,18 @@ public class GlusterUtil { return false; } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getVolume(java.lang.String, java.lang.String) + */ + @Override public Volume getVolume(String volumeName, String knownServer) { return parseVolumeInfo(getVolumeInfo(volumeName, knownServer)).get(0); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getAllVolumes(java.lang.String) + */ + @Override public List<Volume> getAllVolumes(String knownServer) { return parseVolumeInfo(getVolumeInfo(knownServer)); } @@ -415,7 +344,7 @@ public class GlusterUtil { Volume volume = null; for (String line : volumeInfoText.split(CoreConstants.NEWLINE)) { - String volumeName = extractToken(line, VOLUME_NAME_PFX); + String volumeName = StringUtil.extractToken(line, VOLUME_NAME_PFX); if (volumeName != null) { if (volume != null) { volumes.add(volume); @@ -430,7 +359,7 @@ public class GlusterUtil { if (readVolumeType(volume, line)) continue; - if (extractToken(line, VOLUME_NUMBER_OF_BRICKS) != null) { + if (StringUtil.extractToken(line, VOLUME_NUMBER_OF_BRICKS) != null) { readReplicaOrStripeCount(volume, line); } if (readVolumeStatus(volume, line)) @@ -472,6 +401,10 @@ public class GlusterUtil { return volumes; } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#addBricks(java.lang.String, java.util.List, java.lang.String) + */ + @Override public void addBricks(String volumeName, List<String> bricks, String knownServer) { StringBuilder command = new StringBuilder("gluster volume add-brick " + volumeName); for (String brickDir : bricks) { @@ -481,6 +414,10 @@ public class GlusterUtil { serverUtil.executeOnServer(knownServer, command.toString()); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getLogLocation(java.lang.String, java.lang.String, java.lang.String) + */ + @Override public String getLogLocation(String volumeName, String brickName, String knownServer) { String command = "gluster volume log locate " + volumeName + " " + brickName; String output = serverUtil.executeOnServer(knownServer, command, String.class); @@ -492,6 +429,10 @@ public class GlusterUtil { + "] doesn't start with prefix [" + VOLUME_LOG_LOCATION_PFX + "]"); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getLogFileNameForBrickDir(java.lang.String) + */ + @Override public String getLogFileNameForBrickDir(String brickDir) { String logFileName = brickDir; if (logFileName.length() > 0 && logFileName.charAt(0) == '/') { @@ -501,6 +442,10 @@ public class GlusterUtil { return logFileName; } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#removeBricks(java.lang.String, java.util.List, java.lang.String) + */ + @Override public void removeBricks(String volumeName, List<String> bricks, String knownServer) { StringBuilder command = new StringBuilder("gluster --mode=script volume remove-brick " + volumeName); for (String brickDir : bricks) { @@ -509,10 +454,18 @@ public class GlusterUtil { serverUtil.executeOnServer(knownServer, command.toString()); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#removeServer(java.lang.String, java.lang.String) + */ + @Override public void removeServer(String existingServer, String serverName) { serverUtil.executeOnServer(existingServer, "gluster --mode=script peer detach " + serverName); } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#checkRebalanceStatus(java.lang.String, java.lang.String) + */ + @Override public TaskStatus checkRebalanceStatus(String serverName, String volumeName) { String command = "gluster volume rebalance " + volumeName + " status"; String output = serverUtil.executeOnServer(serverName, command, String.class).trim(); @@ -528,45 +481,117 @@ public class GlusterUtil { return taskStatus; } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopRebalance(java.lang.String, java.lang.String) + */ + @Override public void stopRebalance(String serverName, String volumeName) { String command = "gluster volume rebalance " + volumeName + " stop"; serverUtil.executeOnServer(serverName, command); } + + /** + * Performs given Brick Migration (replace-brick) Operation on given volume + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume on which the Brick Migration Operation is to be executed + * @param fromBrick + * The source Brick (being replaced) + * @param toBrick + * The destination Brick (which is replacing the source Brick) + * @param operation + * @return + */ + private String performBrickMigrationOperation(String serverName, String volumeName, String fromBrick, + String toBrick, String operation) { + String command = "gluster volume replace-brick " + volumeName + " " + fromBrick + " " + toBrick + " " + + operation; + return serverUtil.executeOnServer(serverName, command, String.class); + } - public TaskStatus getInitializingDeviceStatus(String serverName, String diskName) { - InitDiskStatusResponse initDiskStatusResponse; - TaskStatus taskStatus = new TaskStatus(); - - try { - initDiskStatusResponse = serverUtil.executeScriptOnServer(serverName, INITIALIZE_DISK_STATUS_SCRIPT + " " - + diskName, InitDiskStatusResponse.class); - } catch(RuntimeException e) { - taskStatus.setCode(Status.STATUS_CODE_FAILURE); - taskStatus.setMessage(e.getMessage()); - throw e; - } + /* + * (non-Javadoc) + * + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#executeBrickMigration(java.lang.String, + * java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void startBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "start"); + } + + /* + * (non-Javadoc) + * @see com.gluster.storage.management.gateway.services.GlusterInterface#pauseBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void pauseBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "pause"); + } + + /* + * (non-Javadoc) + * @see com.gluster.storage.management.gateway.services.GlusterInterface#stopBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void stopBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "abort"); + } + + /* + * (non-Javadoc) + * @see com.gluster.storage.management.gateway.services.GlusterInterface#commitBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void commitBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "commit"); + } + + /* + * (non-Javadoc) + * @see com.gluster.storage.management.gateway.services.GlusterInterface#checkBrickMigrationStatus(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public TaskStatus checkBrickMigrationStatus(String serverName, String volumeName, String fromBrick, String toBrick) { + String output = performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "status"); - if (initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.COMPLETED) { - taskStatus.setCode(Status.STATUS_CODE_SUCCESS); - } else if (initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.IN_PROGRESS) { + TaskStatus taskStatus = new TaskStatus(); + if (output.matches("^Number of files migrated.*Migration complete$") + || output.matches("^Number of files migrated = 0 .*Current file=")) { + // Note: Workaround - if no file in the volume brick to migrate, + // Gluster CLI is not giving proper (complete) status + taskStatus.setCode(Status.STATUS_CODE_COMMIT_PENDING); + taskStatus.setMessage(output.replaceAll("Migration complete", "Commit pending")); + } else if (output.matches("^Number of files migrated.*Current file=.*")) { taskStatus.setCode(Status.STATUS_CODE_RUNNING); - taskStatus.setPercentCompleted(Math.round(initDiskStatusResponse.getCompletedBlocks() - / initDiskStatusResponse.getTotalBlocks() * 100)); - } else if(initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.NOT_RUNNING) { + } else if (output.matches("^replace brick has been paused.*")) { + taskStatus.setCode(Status.STATUS_CODE_PAUSE); + } else { taskStatus.setCode(Status.STATUS_CODE_FAILURE); } - taskStatus.setMessage(initDiskStatusResponse.getMessage()); + taskStatus.setMessage(output); return taskStatus; } - - public String executeBrickMigration(String onlineServerName, String volumeName, String fromBrick, - String toBrick, String operation) { - String command = "gluster volume replace-brick " + volumeName + " " + fromBrick + " " + toBrick + " " + operation; - return serverUtil.executeOnServer(onlineServerName, command, String.class).trim(); - } + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getVolumeOptionsInfo(java.lang.String) + */ + @Override public VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName) { return serverUtil.executeOnServer(serverName, "gluster volume set help-xml", VolumeOptionInfoListResponse.class); } + + public void logRotate(String volumeName, List<String> brickList, String knownServer) { + if (brickList == null || brickList.size() > 0) { + for (String brickDir : brickList) { + serverUtil.executeOnServer(knownServer, "gluster volume log rotate " + volumeName + " " + brickDir); + } + } else { + serverUtil.executeOnServer(knownServer, "gluster volume log rotate " + volumeName); + } + } } diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java new file mode 100644 index 00000000..2df24497 --- /dev/null +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java @@ -0,0 +1,358 @@ +package com.gluster.storage.management.gateway.services; + +import java.util.List; +import java.util.Map; + +import com.gluster.storage.management.core.model.TaskStatus; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; +import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; + +/** + * Interface for interacting with GlusterFS. Every version of GlusterFS supported by the Gluster Management Gateway will + * have a corresponding implementation of this interface. + */ +public interface GlusterInterface { + + /** + * Returns the GlusterFS version on given server. + * + * @param serverName + * Server on which Gluster version is to be checked. + * @return + */ + public abstract String getVersion(String serverName); + + /** + * Adds the new server to an existing cluster. + * + * @param existingServer + * Server part of the existing cluster. + * @param newServer + * Server to be added to the cluster. + */ + public abstract void addServer(String existingServer, String newServer); + + /** + * Removes given server from the cluster by executing appropriate Gluster command on given server. + * + * @param existingServer + * Server part of the existing cluster. + * @param serverName + * Server to be removed from the cluster. + */ + public abstract void removeServer(String existingServer, String serverName); + + /** + * Starts the given volume by executing appropriate Gluster command on given server. + * + * @param volumeName + * Volume to be started. + * @param serverName + * Server on which the Gluster command is to be executed. This server must be part of the cluster to + * which the volume belongs. + */ + public abstract void startVolume(String volumeName, String serverName); + + /** + * Stops the given volume by executing appropriate Gluster command on given server. + * + * @param volumeName + * Volume to be stopped. + * @param serverName + * Server on which the Gluster command is to be executed. This server must be part of the cluster to + * which the volume belongs. + */ + public abstract void stopVolume(String volumeName, String serverName); + + /** + * Resets volume options on the given volume by executing appropriate Gluster command on given server. + * + * @param volumeName + * Volume on which options are to be reset. + * @param serverName + * Server on which the Gluster command is to be executed. This server must be part of the cluster to + * which the volume belongs. + */ + public abstract void resetOptions(String volumeName, String serverName); + + /** + * Creates a volume on given volume using given properties. + * + * @param serverName + * Server on which the Gluster command for creating the volume will be executed. This must be part of the + * cluster in which the volume is to be created. + * @param volumeName + * Name of the volume. + * @param volumeType + * Type of the volume e.g. DISTRIBUTE, REPLICATE, STRIPE, etc. See {@link VOLUME_TYPE} for full list of + * valid values. + * @param transportType + * Transport type of the volume e.g. ETHERNET. See {@link TRANSPORT_TYPE} for full list of valid values. + * @param replOrStripeCount + * Replica Count or Stripe count depending on the volume type. Ignored in case of pure distribute volumes + * (no replicate, no stripe). + * @param bricks + * Comma separated list of volume brick directories in following format: <br> + * server1:dir1,server2:dir2,server3:dir3,...,servern:dirn + * @param accessProtocols + * Optional parameter indicating access protocols to be enabled for the volume. If empty/null, GLUSTERFS + * and NFS will be enabled. + * @param options + * A comma separated list of volume options to be set on the newly created volume in following format: <br> + * key1=value1,key2=value2,key3=value3,...,keyn=valuen + */ + public abstract void createVolume(String serverName, String volumeName, String volumeType, String transportType, + Integer replOrStripeCount, String bricks, String accessProtocols, String options); + + /** + * Creates / Sets the given options on the given volume by executing appropriate Gluster command on the given + * server. + * + * @param volumeName + * Volume on which the options are to be set. + * @param options + * Map containing the volume options to be set. Key = option key, Value = option value. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void createOptions(String volumeName, Map<String, String> options, String serverName); + + /** + * Sets the given option on given volume by executing appropriate Gluster command on the given server. + * + * @param volumeName + * Volume on which the option is to be set. + * @param key + * Option key (name) + * @param value + * Option value + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void setOption(String volumeName, String key, String value, String serverName); + + /** + * Deletes the given volume by executing appropriate Gluster command on the given server. + * + * @param volumeName + * Volume to be deleted. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void deleteVolume(String volumeName, String serverName); + + /** + * Fetches properties of the given Volume by executing appropriate Gluster command on the given server. + * + * @param volumeName + * Volume whose properties are to be fetched. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @return A {@link Volume} object containing all properties of the given volume + */ + public abstract Volume getVolume(String volumeName, String serverName); + + /** + * Fetches the list of all volumes (along with their properties) by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @return A list of {@link Volume} objects representing every volume present in the cluster to which the given + * server belongs. + */ + public abstract List<Volume> getAllVolumes(String serverName); + + /** + * Adds given list of bricks to given Volume by executing appropriate Gluster command on the + * given server. + * + * @param volumeName + * Volume to which the bricks are to be added. + * @param bricks + * List of bricks to be added, each in the format serverName:brickDirectory + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void addBricks(String volumeName, List<String> bricks, String serverName); + + /** + * Removes given list of bricks from given volume by executing appropriate Gluster command on the + * given server. + * + * @param volumeName + * Volume from which the bricks are to be removed + * @param bricks + * List of bricks to be removed, each in the format serverName:brickDirectory + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void removeBricks(String volumeName, List<String> bricks, String serverName); + + /** + * Returns the log location of given brick of given volume by executing appropriate Gluster command on the + * given server. + * + * @param volumeName + * Volume for which log location is to be fetched. + * @param brickName + * Brick of the volume for which log location is to be fetched. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @return Full path of the log file location (directory) for the given Volume Brick. + */ + public abstract String getLogLocation(String volumeName, String brickName, String serverName); + + /** + * Returns the log file name for given brick directory. + * + * @param brickDir + * Brick directory for which log file name is to be returned. + * @return The log file name (without path) for the given brick directory. + */ + public abstract String getLogFileNameForBrickDir(String brickDir); + + /** + * Checks the status of "Rebalance" operation on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose rebalance status is to be checked. + * @return Object of {@link TaskStatus} representing the status of Volume Rebalance. + */ + public abstract TaskStatus checkRebalanceStatus(String serverName, String volumeName); + + /** + * Stops "Rebalance" operation running on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Rebalance is to be stopped. + */ + public abstract void stopRebalance(String serverName, String volumeName); + + /** + * Starts Brick Migration (replace-brick) on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is to be migrated/replaced. + * @param fromBrick + * The source Brick (to be replaced). + * @param toBrick + * The destination Brick (will replace the source Brick). + */ + public abstract void startBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); + + /** + * Pauses Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is being migrated/replaced. + * @param fromBrick + * The source Brick (being replaced). + * @param toBrick + * The destination Brick (which is replacing the source Brick). + */ + public abstract void pauseBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); + + /** + * Aborts Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is being migrated/replaced. + * @param fromBrick + * The source Brick (being replaced). + * @param toBrick + * The destination Brick (which is replacing the source Brick) + */ + public abstract void stopBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); + + /** + * Commits Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is being migrated/replaced. + * @param fromBrick + * The source Brick (being replaced). + * @param toBrick + * The destination Brick (which is replacing the source Brick) + */ + public abstract void commitBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); + + /** + * Checks status of Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command + * on the given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is being migrated/replaced. + * @param fromBrick + * The source Brick (being replaced). + * @param toBrick + * The destination Brick (which is replacing the source Brick) + * @return A {@link TaskStatus} object representing the status of Brick Migration + */ + public abstract TaskStatus checkBrickMigrationStatus(String serverName, String volumeName, String fromBrick, + String toBrick); + + /** + * Returns information about all the supported Volume Options by executing appropriate Gluster command + * on the given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @return A {@link VolumeOptionInfoListResponse} object containing information about each and every supported + * Volume Option + */ + public abstract VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName); + + /** + * Rotates the logs for given Bricks of given Volume by executing appropriate Gluster command + * on the given server. + * + * @param volumeName + * Volume whose logs are to be rotated. + * @param brickList + * List of bricks whose logs are to be rotated, each in the format serverName:brickDirectory <br> + * This is an optional parameter. If null or empty, all logs of the Volume will be rotated. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void logRotate(String volumeName, List<String> brickList, String serverName); +}
\ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java new file mode 100644 index 00000000..2da8d68e --- /dev/null +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java @@ -0,0 +1,256 @@ +/** + * GlusterInterfaceService.java + * + * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com> + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * <http://www.gnu.org/licenses/>. + */ +package com.gluster.storage.management.gateway.services; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.stereotype.Component; + +import com.gluster.storage.management.core.model.TaskStatus; +import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; + +@Component +public class GlusterInterfaceService extends AbstractGlusterInterface { + private HashMap<String, GlusterInterface> glusterInterfaces = new HashMap<String, GlusterInterface>(); + + /** + * Returns an instance of the Gluster Interface for given version of GlusterFS + * @param glusterFsVersion + * @return + */ + private GlusterInterface getGlusterInterfaceForVersion(String glusterFsVersion) { + GlusterInterface glusterInterface = glusterInterfaces.get(glusterFsVersion); + if(glusterInterface != null) { + return glusterInterface; + } + + glusterInterface = new Gluster323InterfaceService(); + glusterInterfaces.put(glusterFsVersion, glusterInterface); + return glusterInterface; + } + + /** + * Returns an instance of Gluster Interface for the version of GlusterFS installed on given server. + * + * @param serverName + * @return + */ + private GlusterInterface getGlusterInterface(String serverName) { + return getGlusterInterfaceForVersion(getVersion(serverName)); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#addServer(java.lang.String, java.lang.String) + */ + @Override + public void addServer(String existingServer, String newServer) { + getGlusterInterface(existingServer).addServer(existingServer, newServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#startVolume(java.lang.String, java.lang.String) + */ + @Override + public void startVolume(String volumeName, String knownServer) { + getGlusterInterface(knownServer).startVolume(volumeName, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopVolume(java.lang.String, java.lang.String) + */ + @Override + public void stopVolume(String volumeName, String knownServer) { + getGlusterInterface(knownServer).stopVolume(volumeName, knownServer); + } + + public void logRotate(String volumeName, List<String> brickList, String knownServer) { + getGlusterInterface(knownServer).logRotate(volumeName, brickList, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#resetOptions(java.lang.String, java.lang.String) + */ + @Override + public void resetOptions(String volumeName, String knownServer) { + getGlusterInterface(knownServer).resetOptions(volumeName, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#createVolume(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void createVolume(String knownServer, String volumeName, String volumeTypeStr, String transportTypeStr, + Integer count, String bricks, String accessProtocols, String options) { + getGlusterInterface(knownServer).createVolume(knownServer, volumeName, volumeTypeStr, transportTypeStr, count, + bricks, accessProtocols, options); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#createOptions(java.lang.String, java.util.Map, java.lang.String) + */ + @Override + public void createOptions(String volumeName, Map<String, String> options, String knownServer) { + getGlusterInterface(knownServer).createOptions(volumeName, options, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#setOption(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void setOption(String volumeName, String key, String value, String knownServer) { + getGlusterInterface(knownServer).setOption(volumeName, key, value, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#deleteVolume(java.lang.String, java.lang.String) + */ + @Override + public void deleteVolume(String volumeName, String knownServer) { + getGlusterInterface(knownServer).deleteVolume(volumeName, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getVolume(java.lang.String, java.lang.String) + */ + @Override + public Volume getVolume(String volumeName, String knownServer) { + return getGlusterInterface(knownServer).getVolume(volumeName, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getAllVolumes(java.lang.String) + */ + @Override + public List<Volume> getAllVolumes(String knownServer) { + return getGlusterInterface(knownServer).getAllVolumes(knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#addBricks(java.lang.String, java.util.List, java.lang.String) + */ + @Override + public void addBricks(String volumeName, List<String> bricks, String knownServer) { + getGlusterInterface(knownServer).addBricks(volumeName, bricks, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getLogLocation(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public String getLogLocation(String volumeName, String brickName, String knownServer) { + return getGlusterInterface(knownServer).getLogLocation(volumeName, brickName, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getLogFileNameForBrickDir(java.lang.String) + */ + @Override + public String getLogFileNameForBrickDir(String brickDir) { + return getGlusterInterface(brickDir.split(":")[0]).getLogFileNameForBrickDir(brickDir); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#removeBricks(java.lang.String, java.util.List, java.lang.String) + */ + @Override + public void removeBricks(String volumeName, List<String> bricks, String knownServer) { + getGlusterInterface(knownServer).removeBricks(volumeName, bricks, knownServer); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#removeServer(java.lang.String, java.lang.String) + */ + @Override + public void removeServer(String existingServer, String serverName) { + getGlusterInterface(serverName).removeServer(existingServer, serverName); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#checkRebalanceStatus(java.lang.String, java.lang.String) + */ + @Override + public TaskStatus checkRebalanceStatus(String serverName, String volumeName) { + return getGlusterInterface(serverName).checkRebalanceStatus(serverName, volumeName); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopRebalance(java.lang.String, java.lang.String) + */ + @Override + public void stopRebalance(String serverName, String volumeName) { + getGlusterInterface(serverName).stopRebalance(serverName, volumeName); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#executeBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void startBrickMigration(String onlineServerName, String volumeName, String fromBrick, String toBrick) { + getGlusterInterface(onlineServerName).startBrickMigration(onlineServerName, volumeName, fromBrick, toBrick); + } + + /* + * (non-Javadoc) + * @see com.gluster.storage.management.gateway.services.GlusterInterface#pauseBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void pauseBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + getGlusterInterface(serverName).pauseBrickMigration(serverName, volumeName, fromBrick, toBrick); + } + + /* + * (non-Javadoc) + * @see com.gluster.storage.management.gateway.services.GlusterInterface#stopBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void stopBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + getGlusterInterface(serverName).stopBrickMigration(serverName, volumeName, fromBrick, toBrick); + } + + /* + * (non-Javadoc) + * @see com.gluster.storage.management.gateway.services.GlusterInterface#commitBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void commitBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + getGlusterInterface(serverName).commitBrickMigration(serverName, volumeName, fromBrick, toBrick); + } + + /* + * (non-Javadoc) + * @see com.gluster.storage.management.gateway.services.GlusterInterface#checkBrickMigrationStatus(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public TaskStatus checkBrickMigrationStatus(String serverName, String volumeName, String fromBrick, String toBrick) { + return getGlusterInterface(serverName).checkBrickMigrationStatus(serverName, volumeName, fromBrick, toBrick); + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getVolumeOptionsInfo(java.lang.String) + */ + @Override + public VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName) { + return getGlusterInterface(serverName).getVolumeOptionsInfo(serverName); + } +} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java index 6cdcd377..da1a8487 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java @@ -34,11 +34,12 @@ import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.exceptions.GlusterValidationException; import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.Server; +import com.gluster.storage.management.core.model.Server.SERVER_STATUS; import com.gluster.storage.management.core.utils.GlusterCoreUtil; import com.gluster.storage.management.core.utils.ProcessUtil; +import com.gluster.storage.management.core.utils.StringUtil; import com.gluster.storage.management.gateway.data.ClusterInfo; import com.gluster.storage.management.gateway.data.ServerInfo; -import com.gluster.storage.management.gateway.utils.GlusterUtil; import com.gluster.storage.management.gateway.utils.ServerUtil; import com.gluster.storage.management.gateway.utils.SshUtil; @@ -47,6 +48,12 @@ import com.gluster.storage.management.gateway.utils.SshUtil; */ @Component public class GlusterServerService { + private static final String HOSTNAME_PFX = "Hostname:"; + private static final String UUID_PFX = "Uuid:"; + private static final String STATE_PFX = "State:"; + private static final String GLUSTER_SERVER_STATUS_ONLINE = "Peer in Cluster (Connected)"; + private static final String GLUSTERD_INFO_FILE = "/etc/glusterd/glusterd.info"; + @Autowired protected ServerUtil serverUtil; @@ -54,7 +61,7 @@ public class GlusterServerService { private ClusterService clusterService; @Autowired - private GlusterUtil glusterUtil; + private GlusterInterfaceService glusterUtil; @Autowired private SshUtil sshUtil; @@ -98,7 +105,7 @@ public class GlusterServerService { Integer maxCount, String previousServerName) { List<GlusterServer> glusterServers; try { - glusterServers = glusterUtil.getGlusterServers(onlineServer); + glusterServers = getGlusterServers(onlineServer.getName()); } catch (Exception e) { // check if online server has gone offline. If yes, try again one more time. if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { @@ -107,7 +114,7 @@ public class GlusterServerService { if (onlineServer == null) { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } - glusterServers = glusterUtil.getGlusterServers(onlineServer); + glusterServers = getGlusterServers(onlineServer.getName()); } else { throw new GlusterRuntimeException(e.getMessage()); } @@ -124,6 +131,85 @@ public class GlusterServerService { } return glusterServers; } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getGlusterServer(com.gluster.storage.management.core.model.GlusterServer, java.lang.String) + */ + public GlusterServer getGlusterServer(String onlineServer, String serverName) { + List<GlusterServer> servers = getGlusterServers(onlineServer); + for (GlusterServer server : servers) { + if (server.getName().equalsIgnoreCase(serverName)) { + return server; + } + } + return null; + } + + private String getUuid(String serverName) { + return serverUtil.executeOnServer(serverName, "cat " + GLUSTERD_INFO_FILE, String.class).split("=")[1]; + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getGlusterServers(com.gluster.storage.management.core.model.GlusterServer) + */ + public List<GlusterServer> getGlusterServers(String knownServerName) { + String output = getPeerStatus(knownServerName); + + GlusterServer knownServer = new GlusterServer(knownServerName); + knownServer.setUuid(getUuid(knownServerName)); + + List<GlusterServer> glusterServers = new ArrayList<GlusterServer>(); + glusterServers.add(knownServer); + + GlusterServer server = null; + boolean foundHost = false; + boolean foundUuid = false; + for (String line : output.split(CoreConstants.NEWLINE)) { + if (foundHost && foundUuid) { + // Host and UUID is found, we should look for state + String state = StringUtil.extractToken(line, STATE_PFX); + if (state != null) { + server.setStatus(state.contains(GLUSTER_SERVER_STATUS_ONLINE) ? SERVER_STATUS.ONLINE + : SERVER_STATUS.OFFLINE); + // Completed populating current server. Add it to the list + // and reset all related variables. + glusterServers.add(server); + + foundHost = false; + foundUuid = false; + server = null; + } + } else if (foundHost) { + // Host is found, look for UUID + String uuid = StringUtil.extractToken(line, UUID_PFX); + if (uuid != null) { + server.setUuid(uuid); + foundUuid = true; + } + } else { + // Look for the next host + if (server == null) { + server = new GlusterServer(); + } + String hostName = StringUtil.extractToken(line, HOSTNAME_PFX); + if (hostName != null) { + server.setName(hostName); + foundHost = true; + } + } + + } + return glusterServers; + } + + /** + * @param knownServer + * A known server on which the gluster command will be executed to fetch peer status + * @return Outout of the "gluster peer status" command + */ + private String getPeerStatus(String knownServer) { + return serverUtil.executeOnServer(knownServer, "gluster peer status", String.class); + } private String fetchDetailsOfServers(List<GlusterServer> glusterServers) { try { @@ -138,16 +224,6 @@ public class GlusterServerService { logger.error(errMsg, e); throw new GlusterRuntimeException(errMsg, e); } -// String errMsg = ""; -// -// for (GlusterServer server : glusterServers) { -// try { -// fetchServerDetails(server); -// } catch (Exception e) { -// errMsg += CoreConstants.NEWLINE + server.getName() + " : [" + e.getMessage() + "]"; -// } -// } -// return errMsg; } private String prepareErrorMessage(List<String> errors) { @@ -238,7 +314,7 @@ public class GlusterServerService { Boolean fetchDetails) { GlusterServer server = null; try { - server = glusterUtil.getGlusterServer(onlineServer, serverName); + server = getGlusterServer(onlineServer.getName(), serverName); } catch (Exception e) { // check if online server has gone offline. If yes, try again one more time. if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { @@ -247,7 +323,7 @@ public class GlusterServerService { if (onlineServer == null) { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } - server = glusterUtil.getGlusterServer(onlineServer, serverName); + server = getGlusterServer(onlineServer.getName(), serverName); } else { throw new GlusterRuntimeException(e.getMessage()); } diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java index eaf99c9c..df33d7ba 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java @@ -59,7 +59,6 @@ import com.gluster.storage.management.gateway.data.ClusterInfo; import com.gluster.storage.management.gateway.resources.v1_0.TasksResource; import com.gluster.storage.management.gateway.tasks.MigrateBrickTask; import com.gluster.storage.management.gateway.tasks.RebalanceVolumeTask; -import com.gluster.storage.management.gateway.utils.GlusterUtil; import com.gluster.storage.management.gateway.utils.ServerUtil; /** @@ -84,7 +83,10 @@ public class VolumeService { private ClusterService clusterService; @Autowired - private GlusterUtil glusterUtil; + private GlusterInterfaceService glusterUtil; + + @Autowired + private GlusterServerService glusterServerService; @Autowired protected ServerUtil serverUtil; @@ -251,7 +253,7 @@ public class VolumeService { try { GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - List<GlusterServer> glusterServers = glusterUtil.getGlusterServers(onlineServer); + List<GlusterServer> glusterServers = glusterServerService.getGlusterServers(onlineServer.getName()); File serversFile = new File(clusterServersListFile); FileOutputStream fos = new FileOutputStream(serversFile); for (GlusterServer server : glusterServers) { diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java index 7586795a..1fba4158 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java @@ -25,24 +25,27 @@ import org.springframework.web.context.ContextLoader; import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.exceptions.ConnectionException; +import com.gluster.storage.management.core.model.InitDiskStatusResponse; import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskInfo; +import com.gluster.storage.management.core.model.InitDiskStatusResponse.FORMAT_STATUS; import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; import com.gluster.storage.management.core.model.TaskStatus; import com.gluster.storage.management.gateway.services.ClusterService; -import com.gluster.storage.management.gateway.utils.GlusterUtil; +import com.gluster.storage.management.gateway.services.GlusterInterfaceService; import com.gluster.storage.management.gateway.utils.ServerUtil; import com.sun.jersey.core.util.Base64; public class InitializeDiskTask extends Task { private static final String INITIALIZE_DISK_SCRIPT = "format_device.py"; + private static final String INITIALIZE_DISK_STATUS_SCRIPT = "get_format_device_status.py"; private String serverName; private String diskName; private String fsType; private ServerUtil serverUtil; - private GlusterUtil glusterUtil; + private GlusterInterfaceService glusterUtil; public InitializeDiskTask(ClusterService clusterService, String clusterName, String serverName, String diskName, String fsType) { @@ -64,7 +67,7 @@ public class InitializeDiskTask extends Task { private void init() { ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); - glusterUtil = ctx.getBean(GlusterUtil.class); + glusterUtil = ctx.getBean(GlusterInterfaceService.class); serverUtil = ctx.getBean(ServerUtil.class); } @@ -130,13 +133,40 @@ public class InitializeDiskTask extends Task { public TaskStatus checkStatus() { try { - return glusterUtil.getInitializingDeviceStatus(serverName, getDiskName()); + return getInitializingDeviceStatus(serverName, getDiskName()); } catch(ConnectionException e) { // online server might have gone offline. update the failure status return new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage())); } } + private TaskStatus getInitializingDeviceStatus(String serverName, String diskName) { + InitDiskStatusResponse initDiskStatusResponse; + TaskStatus taskStatus = new TaskStatus(); + + try { + initDiskStatusResponse = serverUtil.executeScriptOnServer(serverName, INITIALIZE_DISK_STATUS_SCRIPT + " " + + diskName, InitDiskStatusResponse.class); + } catch(RuntimeException e) { + taskStatus.setCode(Status.STATUS_CODE_FAILURE); + taskStatus.setMessage(e.getMessage()); + throw e; + } + + if (initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.COMPLETED) { + taskStatus.setCode(Status.STATUS_CODE_SUCCESS); + } else if (initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.IN_PROGRESS) { + taskStatus.setCode(Status.STATUS_CODE_RUNNING); + taskStatus.setPercentCompleted(Math.round(initDiskStatusResponse.getCompletedBlocks() + / initDiskStatusResponse.getTotalBlocks() * 100)); + } else if(initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.NOT_RUNNING) { + taskStatus.setCode(Status.STATUS_CODE_FAILURE); + } + + taskStatus.setMessage(initDiskStatusResponse.getMessage()); + return taskStatus; + } + public void setDiskName(String diskName) { this.diskName = diskName; } diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java index 5d321d71..e5cb17f1 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java @@ -28,9 +28,8 @@ import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.utils.ProcessResult; import com.gluster.storage.management.gateway.services.ClusterService; -import com.gluster.storage.management.gateway.utils.GlusterUtil; +import com.gluster.storage.management.gateway.services.GlusterInterfaceService; import com.gluster.storage.management.gateway.utils.ServerUtil; import com.sun.jersey.core.util.Base64; @@ -39,7 +38,7 @@ public class MigrateBrickTask extends Task { private String fromBrick; private String toBrick; private Boolean autoCommit; - private GlusterUtil glusterUtil; + private GlusterInterfaceService glusterInterface; protected ServerUtil serverUtil; public String getFromBrick() { @@ -79,7 +78,7 @@ public class MigrateBrickTask extends Task { private void init() { ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); - glusterUtil = ctx.getBean(GlusterUtil.class); + glusterInterface = ctx.getBean(GlusterInterfaceService.class); serverUtil = ctx.getBean(ServerUtil.class); } @@ -106,12 +105,8 @@ public class MigrateBrickTask extends Task { private void startMigration(String onlineServerName) { String volumeName = getTaskInfo().getReference().split("#")[0]; - String output = glusterUtil.executeBrickMigration(onlineServerName, volumeName, - getFromBrick(), getToBrick(), "start"); - if (output.matches(".*started successfully$")) { - getTaskInfo().setStatus( - new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, output))); - } + glusterInterface.startBrickMigration(onlineServerName, volumeName, getFromBrick(), getToBrick()); + getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, "Brick Migration Started."))); } @Override @@ -131,15 +126,11 @@ public class MigrateBrickTask extends Task { private void pauseMigration(String onlineServer) { String volumeName = getTaskInfo().getReference().split("#")[0]; - String output = glusterUtil.executeBrickMigration(onlineServer, volumeName, - getFromBrick(), getToBrick(), "pause"); + glusterInterface.pauseBrickMigration(onlineServer, volumeName, getFromBrick(), getToBrick()); TaskStatus taskStatus = new TaskStatus(); - if (output.matches(".*paused successfully$")) { - taskStatus.setCode(Status.STATUS_CODE_PAUSE); - taskStatus.setMessage(output); - getTaskInfo().setStatus(taskStatus); - return; - } + taskStatus.setCode(Status.STATUS_CODE_PAUSE); + taskStatus.setMessage("Brick Migration Paused"); + getTaskInfo().setStatus(taskStatus); } @Override @@ -164,14 +155,11 @@ public class MigrateBrickTask extends Task { private void commitMigration(String serverName) { String volumeName = getTaskInfo().getReference().split("#")[0]; - String output = glusterUtil.executeBrickMigration(serverName, volumeName, getFromBrick(), getToBrick(), - "commit"); + glusterInterface.commitBrickMigration(serverName, volumeName, getFromBrick(), getToBrick()); TaskStatus taskStatus = new TaskStatus(); - if (output.matches(".*commit successful$")) { - taskStatus.setCode(Status.STATUS_CODE_SUCCESS); - taskStatus.setMessage(output); - getTaskInfo().setStatus(taskStatus); - } + taskStatus.setCode(Status.STATUS_CODE_SUCCESS); + taskStatus.setMessage("Brick Migration Committed."); + getTaskInfo().setStatus(taskStatus); } @Override @@ -191,14 +179,11 @@ public class MigrateBrickTask extends Task { private void stopMigration(String serverName) { String volumeName = getTaskInfo().getReference().split("#")[0]; - String output = glusterUtil.executeBrickMigration(serverName, volumeName, getFromBrick(), - getToBrick(), "abort"); + glusterInterface.stopBrickMigration(serverName, volumeName, getFromBrick(), getToBrick()); TaskStatus taskStatus = new TaskStatus(); - if (output.matches(".*aborted successfully$")) { - taskStatus.setCode(Status.STATUS_CODE_SUCCESS); - taskStatus.setMessage(output); - getTaskInfo().setStatus(taskStatus); - } + taskStatus.setCode(Status.STATUS_CODE_SUCCESS); + taskStatus.setMessage("Brick Migration Stopped"); + getTaskInfo().setStatus(taskStatus); } @Override @@ -217,34 +202,18 @@ public class MigrateBrickTask extends Task { private TaskStatus checkMigrationStatus(String serverName) { // For committed task, status command (CLI) is invalid, just return current status - if (getTaskInfo().getStatus().getCode() == Status.STATUS_CODE_SUCCESS) { - return getTaskInfo().getStatus(); + if (taskInfo.getStatus().getCode() == Status.STATUS_CODE_SUCCESS) { + return taskInfo.getStatus(); } - TaskStatus taskStatus = new TaskStatus(); String volumeName = getTaskInfo().getReference().split("#")[0]; - String output = glusterUtil.executeBrickMigration(serverName, volumeName, getFromBrick(), - getToBrick(), "status"); - - if (output.matches("^Number of files migrated.*Migration complete$") - || output.matches("^Number of files migrated = 0 .*Current file=")) { - // Note: Workaround - if no file in the volume brick to migrate, - // Gluster CLI is not giving proper (complete) status - taskStatus.setCode(Status.STATUS_CODE_COMMIT_PENDING); - if (autoCommit) { - commitMigration(serverName); - return getTaskInfo().getStatus(); // return the committed status - } else { - taskStatus.setMessage(output.replaceAll("Migration complete", "Commit pending")); - } - } else if (output.matches("^Number of files migrated.*Current file=.*")) { - taskStatus.setCode(Status.STATUS_CODE_RUNNING); - } else if (output.matches("^replace brick has been paused.*")) { - taskStatus.setCode(Status.STATUS_CODE_PAUSE); - } else { - taskStatus.setCode(Status.STATUS_CODE_FAILURE); + TaskStatus taskStatus = glusterInterface.checkBrickMigrationStatus(serverName, volumeName, getFromBrick(), + getToBrick()); + if (autoCommit && taskStatus.isCommitPending()) { + commitMigration(serverName); + return taskInfo.getStatus(); // return the committed status } - taskStatus.setMessage(output); + taskInfo.setStatus(taskStatus); // Update the task status return taskStatus; } diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java index d81ea4bf..410260ca 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java @@ -29,7 +29,7 @@ import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; import com.gluster.storage.management.core.model.TaskStatus; import com.gluster.storage.management.gateway.services.ClusterService; -import com.gluster.storage.management.gateway.utils.GlusterUtil; +import com.gluster.storage.management.gateway.services.GlusterInterfaceService; import com.gluster.storage.management.gateway.utils.ServerUtil; import com.sun.jersey.core.util.Base64; @@ -38,7 +38,7 @@ public class RebalanceVolumeTask extends Task { private String layout; private String serverName; private ServerUtil serverUtil; - private GlusterUtil glusterUtil; + private GlusterInterfaceService glusterUtil; public RebalanceVolumeTask(ClusterService clusterService, String clusterName, String volumeName, String layout) { super(clusterService, clusterName, TASK_TYPE.VOLUME_REBALANCE, volumeName, "Volume " + volumeName @@ -51,7 +51,7 @@ public class RebalanceVolumeTask extends Task { private void init() { ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); serverUtil = ctx.getBean(ServerUtil.class); - glusterUtil = ctx.getBean(GlusterUtil.class); + glusterUtil = ctx.getBean(GlusterInterfaceService.class); } @Override |