summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java2
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java3
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java6
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java18
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Task.java66
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskInfo.java91
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java60
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskListResponse.java56
-rwxr-xr-xsrc/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskResponse.java52
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/BrickTableLabelProvider.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java21
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveServerAction.java4
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/jobs/InitializeDiskJob.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/ServerDisksPage.java10
-rwxr-xr-xsrc/com.gluster.storage.management.server.scripts/src/get_server_details.py2
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/TaskResource.java148
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/MigrateDiskTask.java73
18 files changed, 584 insertions, 34 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
index 82b05a91..ae2ead0c 100644
--- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
+++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
@@ -432,7 +432,7 @@ public class GlusterDataModelManager {
}
public String getDiskStatus(Disk disk) {
- if (disk.getStatus() == DISK_STATUS.READY) {
+ if (disk.getStatus() == DISK_STATUS.AVAILABLE) {
for (Volume volume : model.getCluster().getVolumes()) {
if (isDiskUsed(volume, disk)) {
return "In use";
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 428eb53f..4e8e8f33 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
@@ -38,6 +38,7 @@ public class RESTConstants {
public static final String RESOURCE_RUNNING_TASKS = "runningtasks";
public static final String RESOURCE_ALERTS = "alerts";
public static final String RESOURCE_SERVERS = "servers";
+ public static final String RESOURCE_TASKS = "tasks";
public static final String FORM_PARAM_CLUSTER_NAME = "clusterName";
public static final String FORM_PARAM_SERVER_NAME = "serverName";
@@ -56,6 +57,7 @@ public class RESTConstants {
public static final String PATH_PARAM_VOLUME_NAME = "volumeName";
public static final String PATH_PARAM_CLUSTER_NAME = "clusterName";
public static final String PATH_PARAM_SERVER_NAME = "serverName";
+ public static final String PATH_PARAM_TASK_ID = "taskId";
public static final String QUERY_PARAM_BRICK_NAME = "brickName";
public static final String QUERY_PARAM_DISKS = "disks";
@@ -68,4 +70,5 @@ public class RESTConstants {
public static final String QUERY_PARAM_TO_TIMESTAMP = "toTimestamp";
public static final String QUERY_PARAM_DOWNLOAD = "download";
public static final String QUERY_PARAM_SERVER_NAME = "serverName";
+ public static final String QUERY_PARAM_TASK_OPERATION = "taskOperation";
}
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java
index 5b5422da..a399a03a 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java
@@ -27,10 +27,10 @@ import com.gluster.storage.management.core.utils.StringUtil;
@XmlRootElement(name="Disk")
public class Disk extends Entity {
public enum DISK_STATUS {
- READY, UNINITIALIZED, INITIALIZING, IO_ERROR
+ AVAILABLE, UNINITIALIZED, INITIALIZING, IO_ERROR
};
- private String[] DISK_STATUS_STR = { "Ready", "Uninitialized", "Initializing", "I/O Error" };
+ private String[] DISK_STATUS_STR = { "Available", "Uninitialized", "Initializing", "I/O Error" };
private String serverName;
private String mountPoint;
@@ -64,7 +64,7 @@ public class Disk extends Entity {
}
public boolean isReady() {
- return getStatus() == DISK_STATUS.READY;
+ return getStatus() == DISK_STATUS.AVAILABLE;
}
public DISK_STATUS getStatus() {
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java
index 8921287a..8324b22d 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java
@@ -72,7 +72,7 @@ public class GlusterDummyModel {
private void addDiscoveredServer(List<Server> servers, Entity parent, String name, int numOfCPUs, double cpuUsage,
double totalMemory, double memoryInUse, double totalDiskSpace, double diskSpaceInUse) {
Server server = new Server(name, parent, numOfCPUs, cpuUsage, totalMemory, memoryInUse);
- server.addDisk(new Disk(server, "sda", "/export/md0", totalDiskSpace, diskSpaceInUse, DISK_STATUS.READY));
+ server.addDisk(new Disk(server, "sda", "/export/md0", totalDiskSpace, diskSpaceInUse, DISK_STATUS.AVAILABLE));
addNetworkInterface(server, "eth0");
servers.add(server);
@@ -139,18 +139,18 @@ public class GlusterDummyModel {
}
private void initializeDisks() {
- s1da = new Disk(server1, "sda", "/export/md0", 100d, 80d, DISK_STATUS.READY);
- s1db = new Disk(server1, "sdb", "/export/md1", 100d, 67.83, DISK_STATUS.READY);
+ s1da = new Disk(server1, "sda", "/export/md0", 100d, 80d, DISK_STATUS.AVAILABLE);
+ s1db = new Disk(server1, "sdb", "/export/md1", 100d, 67.83, DISK_STATUS.AVAILABLE);
- s2da = new Disk(server2, "sda", "/export/md0", 200d, 157.12, DISK_STATUS.READY);
- s2db = new Disk(server2, "sdb", "/export/md1", 200d, 182.27, DISK_STATUS.READY);
+ s2da = new Disk(server2, "sda", "/export/md0", 200d, 157.12, DISK_STATUS.AVAILABLE);
+ s2db = new Disk(server2, "sdb", "/export/md1", 200d, 182.27, DISK_STATUS.AVAILABLE);
s2dc = new Disk(server2, "sdc", "/export/md0", 200d, -1d, DISK_STATUS.UNINITIALIZED);
- s2dd = new Disk(server2, "sdd", "/export/md1", 200d, 124.89, DISK_STATUS.READY);
+ s2dd = new Disk(server2, "sdd", "/export/md1", 200d, 124.89, DISK_STATUS.AVAILABLE);
- s4da = new Disk(server4, "sda", "/export/md0", 100d, 85.39, DISK_STATUS.READY);
+ s4da = new Disk(server4, "sda", "/export/md0", 100d, 85.39, DISK_STATUS.AVAILABLE);
- s5da = new Disk(server5, "sda", "/export/md1", 100d, 92.83, DISK_STATUS.READY);
- s5db = new Disk(server5, "sdb", "/export/md1", 200d, 185.69, DISK_STATUS.READY);
+ s5da = new Disk(server5, "sda", "/export/md1", 100d, 92.83, DISK_STATUS.AVAILABLE);
+ s5db = new Disk(server5, "sdb", "/export/md1", 200d, 185.69, DISK_STATUS.AVAILABLE);
}
private void addDisksToServers() {
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Task.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Task.java
new file mode 100644
index 00000000..9268d060
--- /dev/null
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Task.java
@@ -0,0 +1,66 @@
+/**
+ * Task.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.core.model;
+
+public abstract class Task {
+ public enum TASK_TYPE {
+ DISK_FORMAT, BRICK_MIGRATE, VOLUME_REBALANCE
+ }
+
+ public String[] TASK_TYPE_STR = { "Format Disk", "Migrate Brick", "Volume Rebalance" };
+
+ private TaskInfo info;
+
+ public Task(TASK_TYPE type, String reference, String description) {
+ info = new TaskInfo();
+ info.setId(getTaskType(type) + "-" + reference); // construct id
+ info.setType(type);
+ info.setReference(reference);
+ info.setDescription(description);
+ }
+ public Task(TaskInfo info) {
+ setInfo(info);
+ }
+
+ public String getTaskType(TASK_TYPE type) {
+ return TASK_TYPE_STR[type.ordinal()];
+ }
+
+ public abstract String getId();
+
+ public abstract TaskInfo resume();
+
+ public abstract TaskInfo stop();
+
+ public abstract TaskInfo pause();
+
+ public abstract TASK_TYPE getType();
+
+ public abstract TaskInfo getTaskInfo();
+
+ public TaskInfo getInfo() {
+ return info;
+ }
+
+ public void setInfo(TaskInfo info) {
+ this.info = info; // TODO: review assigning reference and copy object
+ }
+}
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskInfo.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskInfo.java
new file mode 100644
index 00000000..d4549146
--- /dev/null
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskInfo.java
@@ -0,0 +1,91 @@
+/**
+ * TaskInfo.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.core.model;
+
+import com.gluster.storage.management.core.model.Task.TASK_TYPE;
+
+public class TaskInfo extends Status {
+ private String id;
+ private TASK_TYPE type;
+ private String reference;
+ private String description;
+ private Boolean canPause;
+ private Boolean canStop;
+ private TaskStatus status;
+
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public TASK_TYPE getType() {
+ return type;
+ }
+
+ public void setType(TASK_TYPE type) {
+ this.type = type;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public TaskStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(TaskStatus status) {
+ this.status = status;
+ }
+
+ public Boolean getCanPause() {
+ return canPause;
+ }
+
+ public void setCanPause(Boolean canPause) {
+ this.canPause = canPause;
+ }
+
+ public Boolean getCanStop() {
+ return canStop;
+ }
+
+ public void setCanStop(Boolean canStop) {
+ this.canStop = canStop;
+ }
+
+}
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
new file mode 100644
index 00000000..46dc7b31
--- /dev/null
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java
@@ -0,0 +1,60 @@
+/**
+ * TaskStatus.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.core.model;
+
+public class TaskStatus extends Status {
+
+ private boolean isPercentageSupported;
+ private float percentCompleted;
+ private String description;
+
+ public TaskStatus() {
+
+ }
+
+ public TaskStatus(Status status) {
+ super(status.getCode(), status.getMessage());
+ }
+
+ public boolean isPercentageSupported() {
+ return isPercentageSupported;
+ }
+
+ public void setPercentageSupported(boolean isPercentageSupported) {
+ this.isPercentageSupported = isPercentageSupported;
+ }
+
+ public float getPercentCompleted() {
+ return percentCompleted;
+ }
+
+ public void setPercentCompleted(float percentCompleted) {
+ this.percentCompleted = percentCompleted;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskListResponse.java
new file mode 100644
index 00000000..1bc9b5b5
--- /dev/null
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskListResponse.java
@@ -0,0 +1,56 @@
+/**
+ * TaskListResponse.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.core.response;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.gluster.storage.management.core.model.Status;
+import com.gluster.storage.management.core.model.TaskInfo;
+
+/**
+ * @author root
+ *
+ */
+public class TaskListResponse extends AbstractResponse {
+ private List<TaskInfo> taskList = new ArrayList<TaskInfo>();
+ private Status status;
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+
+ public void setData(List<TaskInfo> taskList) {
+ this.taskList.clear();
+ this.taskList.addAll(taskList);
+ }
+
+ @Override
+ public Object getData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskResponse.java
new file mode 100755
index 00000000..a11c9903
--- /dev/null
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskResponse.java
@@ -0,0 +1,52 @@
+/**
+ * TaskInfoResponse.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.core.response;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import com.gluster.storage.management.core.model.Status;
+import com.gluster.storage.management.core.model.TaskInfo;
+
+@XmlRootElement(name = "response")
+public class TaskResponse extends AbstractResponse {
+ private TaskInfo taskInfo;
+ private Status status;
+
+ public TaskResponse() {
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ public void setData(TaskInfo taskInfo) {
+ this.taskInfo = taskInfo;
+ }
+
+ @Override
+ public TaskInfo getData() {
+ return taskInfo;
+ }
+}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/BrickTableLabelProvider.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/BrickTableLabelProvider.java
index 2d64782b..17e7c7ba 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/BrickTableLabelProvider.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/BrickTableLabelProvider.java
@@ -46,7 +46,7 @@ public class BrickTableLabelProvider extends TableLabelProviderAdapter {
if (columnIndex == DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) {
DISK_STATUS status = disk.getStatus();
switch (status) {
- case READY:
+ case AVAILABLE:
return guiHelper.getImage(IImageKeys.STATUS_ONLINE);
case IO_ERROR:
return guiHelper.getImage(IImageKeys.STATUS_OFFLINE);
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java
index c355ac50..539b70d7 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java
@@ -46,7 +46,7 @@ public class DiskTableLabelProvider extends TableLabelProviderAdapter {
if (columnIndex == DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) {
DISK_STATUS status = disk.getStatus();
switch (status) {
- case READY:
+ case AVAILABLE:
return guiHelper.getImage(IImageKeys.STATUS_ONLINE);
case IO_ERROR:
return guiHelper.getImage(IImageKeys.STATUS_OFFLINE);
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java
index 57a7b312..80625779 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java
@@ -43,7 +43,7 @@ public class ServerDiskTableLabelProvider extends TableLabelProviderAdapter {
if (columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) {
DISK_STATUS status = disk.getStatus();
switch (status) {
- case READY:
+ case AVAILABLE:
return guiHelper.getImage(IImageKeys.STATUS_ONLINE);
case IO_ERROR:
return guiHelper.getImage(IImageKeys.STATUS_OFFLINE);
@@ -59,17 +59,18 @@ public class ServerDiskTableLabelProvider extends TableLabelProviderAdapter {
return null;
}
- private String getDiskSpaceInUse(Disk disk) {
- if(disk.hasErrors() || disk.isUninitialized()) {
- return CoreConstants.NA;
+
+ private String getDiskFreeSpace(Disk disk) {
+ if (disk.hasErrors() || disk.isUninitialized()) {
+ return "NA";
} else {
- return NumberUtil.formatNumber(disk.getSpaceInUse());
+ return NumberUtil.formatNumber(disk.getFreeSpace());
}
}
- private String getDiskSpace(Disk disk) {
- if(disk.hasErrors() || disk.isUninitialized()) {
- return CoreConstants.NA;
+ private String getTotalDiskSpace(Disk disk) {
+ if (disk.hasErrors() || disk.isUninitialized()) {
+ return "NA";
} else {
return NumberUtil.formatNumber(disk.getSpace());
}
@@ -83,8 +84,8 @@ public class ServerDiskTableLabelProvider extends TableLabelProviderAdapter {
Disk disk = (Disk) element;
String columnText = (columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.DISK.ordinal() ? disk.getName()
- : columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.SPACE.ordinal() ? getDiskSpace(disk)
- : columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.SPACE_IN_USE.ordinal() ? getDiskSpaceInUse(disk)
+ : columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal() ? getDiskFreeSpace(disk)
+ : columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal() ? getTotalDiskSpace(disk)
: columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal() ? glusterDataModelManager.getDiskStatus(disk) // disk.getStatusStr()
: "Invalid");
return ((columnText == null || columnText.trim().equals("")) ? CoreConstants.NA : columnText);
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveServerAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveServerAction.java
index 83489c37..514fd0a5 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveServerAction.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveServerAction.java
@@ -129,7 +129,7 @@ public class RemoveServerAction extends AbstractActionDelegate {
if (usedServers.size() == 1) {
showErrorDialog(action.getDescription(), "Server [" + usedServers.keySet().iterator().next()
+ "] cannot be removed as it is being used by volume(s): " + CoreConstants.NEWLINE
- + usedServers.values().iterator().next() + "]");
+ + usedServers.values().iterator().next() );
} else {
String serverList = "";
for (Entry<GlusterServer, List<String>> entry : usedServers.entrySet()) {
@@ -137,7 +137,7 @@ public class RemoveServerAction extends AbstractActionDelegate {
}
showErrorDialog(action.getDescription(),
"Following servers cannot be removed as they are being used by volume(s): "
- + CoreConstants.NEWLINE + serverList + "]");
+ + CoreConstants.NEWLINE + serverList );
}
return false;
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/jobs/InitializeDiskJob.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/jobs/InitializeDiskJob.java
index b5945e61..02a8b0e0 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/jobs/InitializeDiskJob.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/jobs/InitializeDiskJob.java
@@ -76,7 +76,7 @@ public class InitializeDiskJob extends Job {
e.printStackTrace();
}
- updateStatus(DISK_STATUS.READY);
+ updateStatus(DISK_STATUS.AVAILABLE);
setProperty(IProgressConstants.ICON_PROPERTY, guiHelper.getImageDescriptor(IImageKeys.STATUS_SUCCESS));
return new Status(Status.OK, Application.PLUGIN_ID, "Task Completed!");
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/ServerDisksPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/ServerDisksPage.java
index c2f76a43..b993f73e 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/ServerDisksPage.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/ServerDisksPage.java
@@ -35,11 +35,11 @@ public class ServerDisksPage extends AbstractDisksPage {
}
public enum SERVER_DISK_TABLE_COLUMN_INDICES {
- DISK, SPACE, SPACE_IN_USE, STATUS
+ DISK, FREE_SPACE, TOTAL_SPACE, STATUS
};
- private static final String[] SERVER_DISK_TABLE_COLUMN_NAMES = new String[] { "Disk", "Space (GB)",
- "Space in Use (GB)", "Status" };
+ private static final String[] SERVER_DISK_TABLE_COLUMN_NAMES = new String[] { "Disk", "Free Space (GB)",
+ "Total Space (GB)", "Status" };
@Override
protected String[] getColumnNames() {
@@ -49,8 +49,8 @@ public class ServerDisksPage extends AbstractDisksPage {
@Override
protected void setColumnProperties(Table table) {
guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.DISK.ordinal(), SWT.CENTER, 100);
- guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.SPACE.ordinal(), SWT.CENTER, 90);
- guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.SPACE_IN_USE.ordinal(), SWT.CENTER, 90);
+ guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal(), SWT.CENTER, 90);
+ guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal(), SWT.CENTER, 90);
guiHelper.setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal(), SWT.LEFT, 90);
}
diff --git a/src/com.gluster.storage.management.server.scripts/src/get_server_details.py b/src/com.gluster.storage.management.server.scripts/src/get_server_details.py
index 079c5f5b..ce1d97e6 100755
--- a/src/com.gluster.storage.management.server.scripts/src/get_server_details.py
+++ b/src/com.gluster.storage.management.server.scripts/src/get_server_details.py
@@ -133,7 +133,7 @@ def getServerDetails(listall):
if used:
partitionTag.appendChild(responseDom.createTag("spaceInUse", str(used)))
diskSpaceInUse += used
- partitionTag.appendChild(responseDom.createTag("status", "READY"))
+ partitionTag.appendChild(responseDom.createTag("status", "AVAILABLE"))
else:
partitionTag.appendChild(responseDom.createTag("spaceInUse", "NA"))
partitionTag.appendChild(responseDom.createTag("status", "UNINITIALIZED"))
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/TaskResource.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/TaskResource.java
new file mode 100644
index 00000000..c5540dff
--- /dev/null
+++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/TaskResource.java
@@ -0,0 +1,148 @@
+/**
+ * TaskResource.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.server.resources;
+
+import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME;
+import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_TASK_ID;
+import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_TASK_OPERATION;
+import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS;
+import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_TASKS;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import com.gluster.storage.management.core.exceptions.GlusterRuntimeException;
+import com.gluster.storage.management.core.model.Status;
+import com.gluster.storage.management.core.model.Task;
+import com.gluster.storage.management.core.model.Task.TASK_TYPE;
+import com.gluster.storage.management.core.model.TaskInfo;
+import com.gluster.storage.management.core.response.TaskListResponse;
+import com.gluster.storage.management.core.response.TaskResponse;
+import com.gluster.storage.management.server.runningtasks.managers.MigrateDiskManager;
+import com.gluster.storage.management.server.tasks.MigrateDiskTask;
+import com.sun.jersey.spi.resource.Singleton;
+
+@Path(RESOURCE_PATH_CLUSTERS + "/{" + PATH_PARAM_CLUSTER_NAME + "}/" + RESOURCE_TASKS)
+@Singleton
+public class TaskResource {
+ private Map<String, Task> tasks;
+
+ private TaskResource() {
+ }
+
+ public void addTask(Task task) {
+ tasks.put(task.getId(), task);
+ }
+
+ public void removeTask(Task task) {
+ tasks.remove(task);
+ }
+
+ public List<Task> getAllTasks() {
+ List<Task> allTasks = new ArrayList<Task>();
+ for (Map.Entry<String, Task> entry : tasks.entrySet()) {
+ allTasks.add(entry.getValue());
+ }
+ return allTasks;
+ }
+
+ public Task getTask(String taskId) {
+ for (Map.Entry<String, Task> entry : tasks.entrySet()) {
+ if (entry.getValue().getId().equals(taskId)) {
+ return entry.getValue();
+ }
+ }
+ return null;
+ }
+
+ @GET
+ @Produces(MediaType.TEXT_XML)
+ public TaskListResponse getTasks() {
+ TaskListResponse taskListResponse = new TaskListResponse();
+ List<TaskInfo> taskInfoList = new ArrayList<TaskInfo>();
+ try {
+ for (Task task : getAllTasks()) {
+ taskInfoList.add(task.getTaskInfo());
+ }
+ taskListResponse.setData(taskInfoList);
+ taskListResponse.setStatus(new Status(Status.STATUS_CODE_SUCCESS, ""));
+ } catch (GlusterRuntimeException e) {
+ taskListResponse.setStatus(new Status(e));
+ }
+ return taskListResponse;
+ }
+
+ @PUT
+ @Path("/{" + PATH_PARAM_TASK_ID + "}")
+ @Produces(MediaType.TEXT_XML)
+ public TaskResponse performTask(@PathParam(PATH_PARAM_TASK_ID) String taskId,
+ @QueryParam(QUERY_PARAM_TASK_OPERATION) String taskOperation) {
+ Task task = getTask(taskId);
+ TaskInfo taskInfo = null;
+ TaskResponse taskResponse = new TaskResponse();
+
+ try {
+ if (taskOperation.equals("resume")) {
+ taskInfo = task.resume();
+ }
+ if (taskOperation.equals("pause")) {
+ taskInfo = task.pause();
+ }
+ if (taskOperation.equals("stop")) {
+ taskInfo = task.stop();
+ }
+ taskResponse.setData(taskInfo);
+ taskResponse.setStatus(new Status(Status.STATUS_CODE_SUCCESS, ""));
+ } catch (GlusterRuntimeException e) {
+ taskResponse.setStatus(new Status(e));
+ }
+ return taskResponse;
+ }
+
+ @DELETE
+ @Path("/{" + PATH_PARAM_TASK_ID + "}")
+ @Produces(MediaType.TEXT_XML)
+ public TaskResponse deleteTask(@PathParam(PATH_PARAM_TASK_ID) String taskId,
+ @QueryParam(QUERY_PARAM_TASK_OPERATION) String taskOperation) {
+ TaskResponse taskResponse = new TaskResponse();
+ Task task = getTask(taskId);
+ if (task == null) {
+ taskResponse.setStatus( new Status(Status.STATUS_CODE_FAILURE, "No such task " + taskId + "is found "));
+ }
+ if (taskOperation.equals("delete")) {
+ removeTask(task);
+ taskResponse.setStatus(new Status(Status.STATUS_CODE_SUCCESS, "Task [" + taskId
+ + "] removed successfully"));
+ }
+ return null;
+ }
+
+}
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/MigrateDiskTask.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/MigrateDiskTask.java
new file mode 100644
index 00000000..97f3d2aa
--- /dev/null
+++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/MigrateDiskTask.java
@@ -0,0 +1,73 @@
+/**
+ * MigrateDiskTask.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.server.tasks;
+
+import com.gluster.storage.management.core.model.Task;
+import com.gluster.storage.management.core.model.TaskInfo;
+
+public class MigrateDiskTask extends Task {
+
+ public MigrateDiskTask(TASK_TYPE type, String reference, String description ) {
+ super(type, reference, description );
+ }
+
+ public MigrateDiskTask(TaskInfo info) {
+ super(info);
+ }
+
+
+ @Override
+ public String getId() {
+ return getInfo().getId();
+ }
+
+ @Override
+ public TaskInfo resume() {
+ // To make a decision is the task has the ability to start the task
+ return null;
+ }
+
+
+ @Override
+ public TaskInfo stop() {
+ // To make a decision is the task has the ability to stop the task
+ return null;
+ }
+
+
+ @Override
+ public TaskInfo pause() {
+ // To make a decision is the task has the ability to pause the task
+ return null;
+ }
+
+
+ @Override
+ public TASK_TYPE getType() {
+
+ return null;
+ }
+
+ @Override
+ public TaskInfo getTaskInfo() {
+ return getInfo();
+ }
+}