summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhandapani <dhandapani@gluster.com>2011-09-28 15:51:45 +0530
committerDhandapani <dhandapani@gluster.com>2011-09-29 14:44:14 +0530
commitc2fcd1775f60ddf7f3a3be39d7d9b70fa00da90a (patch)
tree06c148138c60f4303228ead1af73de91a223ff3f
parentdb1784e5e95ea4c4a2b0ab41da862868834099d0 (diff)
Story #41: Volume Log Rotate
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java8
-rw-r--r--src/com.gluster.storage.management.console/plugin.xml18
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/VolumeLogRotateAction.java64
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java1
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java7
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java21
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java10
7 files changed, 128 insertions, 1 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java
index 4c75c375..f85afd4d 100644
--- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java
+++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java
@@ -258,6 +258,14 @@ public class VolumesClient extends AbstractClient {
putRequest(volumeName, form);
}
+ public void volumeLogRotate(String volumeName, List<String> brickList) {
+ Form form = new Form();
+ String bricks = StringUtil.collectionToString(brickList, ",");
+ form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_LOG_ROTATE);
+ form.add(FORM_PARAM_BRICKS, bricks);
+ putRequest(volumeName, form);
+ }
+
public static void main(String[] args) {
UsersClient usersClient = new UsersClient();
try {
diff --git a/src/com.gluster.storage.management.console/plugin.xml b/src/com.gluster.storage.management.console/plugin.xml
index e7c2c2d4..6983b9dd 100644
--- a/src/com.gluster.storage.management.console/plugin.xml
+++ b/src/com.gluster.storage.management.console/plugin.xml
@@ -302,6 +302,11 @@
id="com.gluster.storage.management.console.commands.Preferences"
name="Settings">
</command>
+ <command
+ description="Volume Log Rotate"
+ id="com.gluster.storage.management.console.commands.LogRotate"
+ name="LogRotate">
+ </command>
</extension>
<extension
point="org.eclipse.ui.bindings">
@@ -521,6 +526,19 @@
label="Volume Actions"
visible="false">
<action
+ class="com.gluster.storage.management.console.actions.VolumeLogRotateAction"
+ definitionId="com.gluster.storage.management.console.commands.LogRotate"
+ icon="icons/tango/32x32/download-log.png"
+ id="com.gluster.storage.management.console.actions.LogRotateAction"
+ label="L&amp;og Rotate"
+ menubarPath="com.gluster.storage.management.console.menu.volume/volume"
+ pulldown="false"
+ state="true"
+ style="push"
+ toolbarPath="Normal"
+ tooltip="Rotate the volume logs">
+ </action>
+ <action
allowLabelUpdate="false"
class="com.gluster.storage.management.console.actions.MigrateBrickAction"
definitionId="com.gluster.storage.management.console.commands.MigrateDisk"
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/VolumeLogRotateAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/VolumeLogRotateAction.java
new file mode 100644
index 00000000..2cef74b5
--- /dev/null
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/VolumeLogRotateAction.java
@@ -0,0 +1,64 @@
+package com.gluster.storage.management.console.actions;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+import com.gluster.storage.management.client.VolumesClient;
+import com.gluster.storage.management.console.utils.GUIHelper;
+import com.gluster.storage.management.console.views.VolumeBricksView;
+import com.gluster.storage.management.core.model.Brick;
+import com.gluster.storage.management.core.model.Volume;
+import com.gluster.storage.management.core.utils.GlusterCoreUtil;
+
+
+public class VolumeLogRotateAction extends AbstractActionDelegate {
+
+ private Volume volume;
+ private GUIHelper guiHelper = GUIHelper.getInstance();
+ private Set<Brick> bricks;
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ protected void performAction(IAction action) {
+ final String actionDesc = action.getDescription();
+ List<String> selectedBricks = new ArrayList<String>();
+ boolean confirmed = showConfirmDialog(actionDesc,
+ "Are you sure you want to Rotate logs for volume [" + volume.getName() + "] ? ");
+ if (!confirmed) {
+ return;
+ }
+
+ if (bricks != null) {
+ selectedBricks = GlusterCoreUtil.getQualifiedBrickList(bricks);
+ }
+ try {
+ new VolumesClient().volumeLogRotate(volume.getName(), selectedBricks);
+ showInfoDialog(actionDesc, "Volume logs for [" + volume.getName() + "] rotated successfully!");
+ } catch (Exception e) {
+ showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] log rotation failed! Error: [" + e.getMessage() + "]");
+ }
+ }
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ super.selectionChanged(action, selection);
+ volume = (Volume) guiHelper.getSelectedEntity(window, Volume.class);
+
+ if (volume != null) {
+ // a volume is selected on navigation tree. Let's check if the currently open view is volume bricks view
+ IWorkbenchPart view = guiHelper.getActiveView();
+ if (view instanceof VolumeBricksView) {
+ // volume bricks view is open. check if any brick is selected
+ bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class);
+ }
+ }
+ }
+
+}
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java
index 3e42b1c0..3db8bf90 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java
@@ -52,6 +52,7 @@ public class RESTConstants {
public static final String TASK_COMMIT = "commit";
public static final String TASK_STATUS = "status";
public static final String TASK_DELETE = "delete";
+ public static final String TASK_LOG_ROTATE = "logRotate";
public static final String TASK_REBALANCE_START = "rebalanceStart";
public static final String TASK_REBALANCE_STATUS = "rebalanceStatus";
public static final String TASK_REBALANCE_STOP = "rebalanceStop";
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java
index b892df32..4303aa63 100644
--- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java
+++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java
@@ -59,6 +59,7 @@ import static com.gluster.storage.management.core.constants.RESTConstants.RESOUR
import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_VOLUMES;
import java.io.File;
+import java.util.Arrays;
import java.util.List;
import javax.ws.rs.DELETE;
@@ -193,7 +194,8 @@ public class VolumesResource extends AbstractResource {
@FormParam(FORM_PARAM_FIX_LAYOUT) Boolean isFixLayout,
@FormParam(FORM_PARAM_MIGRATE_DATA) Boolean isMigrateData,
@FormParam(FORM_PARAM_FORCED_DATA_MIGRATE) Boolean isForcedDataMigrate,
- @FormParam(FORM_PARAM_CIFS_ENABLE) Boolean enableCifs, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers) {
+ @FormParam(FORM_PARAM_CIFS_ENABLE) Boolean enableCifs, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers,
+ @FormParam(FORM_PARAM_BRICKS) String bricks) {
if (clusterName == null || clusterName.isEmpty()) {
throw new GlusterValidationException("Cluster name must not be empty!");
}
@@ -228,6 +230,9 @@ public class VolumesResource extends AbstractResource {
}
volumeService.deleteCifsUsers(clusterName, volumeName);
}
+ } else if (operation.equals(RESTConstants.TASK_LOG_ROTATE)) {
+ List<String> brickList = Arrays.asList(bricks.split(","));
+ volumeService.logRotate(clusterName, volumeName, brickList);
} else {
volumeService.performVolumeOperation(clusterName, volumeName, operation);
}
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 eb585b98..b0894a5c 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
@@ -686,6 +686,27 @@ public class VolumeService {
}
}
+ public void logRotate(String clusterName, String volumeName, List<String> brickList) {
+ GlusterServer onlineServer = clusterService.getOnlineServer(clusterName);
+ try {
+ if (onlineServer == null) {
+ throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]");
+ }
+
+ glusterUtil.logRotate(volumeName, brickList, 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) {
+ // online server has gone offline! try with a different one.
+ onlineServer = clusterService.getNewOnlineServer(clusterName);
+ glusterUtil.logRotate(volumeName, brickList, onlineServer.getName());
+ } else {
+ throw new GlusterRuntimeException("Volume [" + volumeName + "] log rotation failed!", e);
+ }
+ }
+ }
+
+
public void performVolumeOperation(String clusterName, String volumeName, String operation) {
GlusterServer onlineServer = clusterService.getOnlineServer(clusterName);
try {
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/utils/GlusterUtil.java
index 3bcd5826..a7a96ccd 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/utils/GlusterUtil.java
@@ -180,6 +180,16 @@ public class GlusterUtil {
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);
+ }
+ }
public void resetOptions(String volumeName, String knownServer) {
serverUtil.executeOnServer(knownServer, "gluster volume reset " + volumeName);