diff options
| author | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-08-18 10:39:11 -0700 |
|---|---|---|
| committer | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-08-18 10:39:11 -0700 |
| commit | 2db8ff2fc0cf67933b4594fc4d11cb1e996b7175 (patch) | |
| tree | d97309a913419a3cf2e705a6f9e6271adf404e8e /src/com.gluster.storage.management.gateway | |
| parent | 3db6ac956fea2138d2a1b09022612b8c6ead2df9 (diff) | |
| parent | 91d73541f74bb0fa98484e04eee2ad538a317e0f (diff) | |
Merge pull request #250 from Selvasundaram/master
Deleting CIFS config throws null pointer exception bug - fix
Diffstat (limited to 'src/com.gluster.storage.management.gateway')
5 files changed, 87 insertions, 49 deletions
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java index d4a8bedf..89143129 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java @@ -217,12 +217,13 @@ public class GlusterServersResource extends AbstractResource { if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); + } + glusterUtil.addServer(onlineServer.getName(), serverName); + } else { + throw new GlusterRuntimeException(e.getMessage()); } - if (onlineServer == null) { - throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); - } - - glusterUtil.addServer(onlineServer.getName(), 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 d4f484f4..72e414fc 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 @@ -81,12 +81,15 @@ public class GlusterServerService { // check if online server has gone offline. If yes, try again one more time. if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - } - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterServers = getGlusterServers(clusterName, onlineServer, fetchDetails, maxCount, previousServerName); + } else { + throw new GlusterRuntimeException(e.getMessage()); } - glusterServers = getGlusterServers(clusterName, onlineServer, fetchDetails, maxCount, previousServerName); + } return glusterServers; } @@ -101,12 +104,13 @@ public class GlusterServerService { if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterServers = glusterUtil.getGlusterServers(onlineServer); + } else { + throw new GlusterRuntimeException(e.getMessage()); } - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - glusterServers = glusterUtil.getGlusterServers(onlineServer); } // skip the servers by maxCount / previousServerName @@ -166,11 +170,13 @@ public class GlusterServerService { if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + server = glusterUtil.getGlusterServer(onlineServer, serverName); + } else { + throw new GlusterRuntimeException(e.getMessage()); } - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - server = glusterUtil.getGlusterServer(onlineServer, serverName); } if (fetchDetails && server.isOnline()) { @@ -226,11 +232,13 @@ public class GlusterServerService { if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName, serverName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); + } + glusterUtil.removeServer(onlineServer.getName(), serverName); + } else { + throw new GlusterRuntimeException(e.getMessage()); } - if (onlineServer == null) { - throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); - } - glusterUtil.removeServer(onlineServer.getName(), serverName); } try { 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 a0bee373..48a12435 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 @@ -43,6 +43,7 @@ import com.gluster.storage.management.core.exceptions.GlusterValidationException import com.gluster.storage.management.core.model.Brick; import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.model.Server.SERVER_STATUS; import com.gluster.storage.management.core.model.Volume.NAS_PROTOCOL; import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; @@ -126,8 +127,9 @@ public class VolumeService { if (onlineServer == null) { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } - glusterUtil.addBricks(volumeName, brickList, onlineServer.getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); } } } @@ -159,10 +161,12 @@ public class VolumeService { if (onlineServer == null) { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } + volume = glusterUtil.getVolume(volumeName, onlineServer.getName()); + // Collect the CIFS users if CIFS Re-exported + fetchVolumeCifsUsers(clusterName, volume); + } else { + throw new GlusterRuntimeException(e.getMessage()); } - volume = glusterUtil.getVolume(volumeName, onlineServer.getName()); - // Collect the CIFS users if CIFS Re-exported - fetchVolumeCifsUsers(clusterName, volume); } return volume; } @@ -250,7 +254,9 @@ public class VolumeService { File serversFile = new File(clusterServersListFile); FileOutputStream fos = new FileOutputStream(serversFile); for (GlusterServer server : glusterServers) { - fos.write((server.getName() + CoreConstants.NEWLINE).getBytes()); + if (server.getStatus() == SERVER_STATUS.ONLINE) { + fos.write((server.getName() + CoreConstants.NEWLINE).getBytes()); + } } fos.close(); return serversFile; @@ -351,13 +357,12 @@ public class VolumeService { // To clear all the volume CIFS configurations from the server public void clearCifsConfiguration(String clusterName, String onlineServerName, String serverName) { - VolumeService volumeService = new VolumeService(); File volumesFile = createOnlineVolumeList(clusterName, onlineServerName); if (volumesFile == null) { return; } try { - volumeService.removeServerVolumeCifsConfig(serverName, volumesFile.getAbsolutePath()); + removeServerVolumeCifsConfig(serverName, volumesFile.getAbsolutePath()); volumesFile.delete(); } catch(Exception e) { volumesFile.delete(); @@ -371,7 +376,7 @@ public class VolumeService { + ALL_ONLINE_VOLUMES_FILE_NAME + "_" + timestamp; try { List<Volume> volumes = getVolumes(clusterName); - if (volumes.size() == 0) { + if (volumes == null || volumes.size() == 0) { return null; } File volumesFile = new File(volumeListFileName); @@ -428,10 +433,11 @@ public class VolumeService { if (onlineServer == null) { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } + glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, replicaCount, + stripeCount, bricks, accessProtocols, options); + } else { + throw new GlusterRuntimeException(e.getMessage()); } - - glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, replicaCount, - stripeCount, bricks, accessProtocols, options); } List<String> nasProtocols = Arrays.asList(accessProtocols.split(",")); @@ -690,6 +696,8 @@ public class VolumeService { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); performOperation(clusterName, volumeName, operation, onlineServer); + } else { + throw new GlusterRuntimeException(e.getMessage()); } } } @@ -752,11 +760,13 @@ public class VolumeService { if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterUtil.removeBricks(volumeName, brickList, onlineServer.getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); } - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - glusterUtil.removeBricks(volumeName, brickList, onlineServer.getName()); } } @@ -859,12 +869,15 @@ public class VolumeService { if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); - } - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } - glusterUtil.resetOptions(volumeName, onlineServer.getName()); + glusterUtil.resetOptions(volumeName, onlineServer.getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } } @@ -901,12 +914,15 @@ public class VolumeService { if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterUtil.setOption(volumeName, key, value, onlineServer.getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); } - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - glusterUtil.setOption(volumeName, key, value, onlineServer.getName()); + + } } } 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 a1fce1eb..e7dd9c02 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 @@ -25,6 +25,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.web.context.ContextLoader; import com.gluster.storage.management.core.exceptions.ConnectionException; +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; @@ -99,6 +100,8 @@ public class MigrateBrickTask extends Task { if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { // online server might have gone Offline. try with a new one. startMigration(getNewOnlineServer().getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); } } } @@ -123,6 +126,8 @@ public class MigrateBrickTask extends Task { if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { // online server might have gone offline. try with a new one. pauseMigration(getNewOnlineServer().getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); } } } @@ -154,6 +159,8 @@ public class MigrateBrickTask extends Task { if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { // online server might have gone offline. try with a new one. commitMigration(getNewOnlineServer().getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); } } } @@ -181,6 +188,8 @@ public class MigrateBrickTask extends Task { if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { // online server might have gone offline. try with a new one. stopMigration(getNewOnlineServer().getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); } } } @@ -206,7 +215,7 @@ public class MigrateBrickTask extends Task { if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { // online server might have gone offline. try with a new one. return checkMigrationStatus(getNewOnlineServer().getName()); - } + } } return null; } 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 8c844f5b..89636fdf 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 @@ -72,6 +72,8 @@ public class RebalanceVolumeTask extends Task { // online server might have gone offline. try with a new one serverName = getNewOnlineServer().getName(); startRebalance(serverName); + } else { + throw new GlusterRuntimeException(e.getMessage()); } } } @@ -98,6 +100,8 @@ public class RebalanceVolumeTask extends Task { if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { // online server might have gone offline. update the failure status getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage()))); + } else { + throw new GlusterRuntimeException(e.getMessage()); } } } |
