summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.core
diff options
context:
space:
mode:
authorSelvam <selvam@gluster.com>2011-04-20 10:55:26 +0530
committerSelvam <selvam@gluster.com>2011-04-29 14:54:40 +0530
commit3cc0768e0baf35ea140262e4f646cbdb9a3b8b84 (patch)
tree3e23f01b7270667028592b3ce054374ce8bafdcf /src/com.gluster.storage.management.core
parentc11192c4cf06f14ad90d72819ebeee2ad527f16d (diff)
Story #18 Add disk, UI, REST client and REST Resource
Diffstat (limited to 'src/com.gluster.storage.management.core')
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java2
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java8
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java38
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java21
4 files changed, 61 insertions, 8 deletions
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 0aa286a3..4bd0d292 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
@@ -29,6 +29,7 @@ public class RESTConstants {
public static final String SUBRESOURCE_DEFAULT_OPTIONS = "defaultoptions";
public static final String SUBRESOURCE_OPTIONS = "options";
public static final String SUBRESOURCE_LOGS = "logs";
+ public static final String SUBRESOURCE_DISKS = "disks";
public static final String FORM_PARAM_OPERATION = "operation";
@@ -41,6 +42,7 @@ public class RESTConstants {
public static final String FORM_PARAM_DELETE_OPTION = "value";
public static final String QUERY_PARAM_DISK_NAME = "diskName";
+ public static final String QUERY_PARAM_DISKS = "disks";
public static final String QUERY_PARAM_LINE_COUNT = "lineCount";
public static final String QUERY_PARAM_VOLUME_NAME = "volumeName";
public static final String QUERY_PARAM_DELETE_OPTION = "deleteOption";
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java
index 94b23179..b43381e5 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java
@@ -49,6 +49,10 @@ public class Volume extends Entity {
GLUSTERFS, NFS
};
+
+ public static final int DEFAULT_REPLICA_COUNT = 2;
+ public static final int DEFAULT_STRIPE_COUNT = 4;
+
public static final String OPTION_AUTH_ALLOW = "auth.allow";
private static final String[] VOLUME_TYPE_STR = new String[] { "Plain Distribute", "Distributed Mirror",
@@ -104,9 +108,9 @@ public class Volume extends Entity {
// TODO find a way to get the replica / strip count
if (volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) {
setReplicaCount(0);
- setStripeCount(3);
+ setStripeCount(DEFAULT_STRIPE_COUNT);
} else if (volumeType == VOLUME_TYPE.DISTRIBUTED_MIRROR) {
- setReplicaCount(2);
+ setReplicaCount(DEFAULT_REPLICA_COUNT);
setStripeCount(0);
} else {
setReplicaCount(0);
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java
new file mode 100644
index 00000000..9e3084fb
--- /dev/null
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java
@@ -0,0 +1,38 @@
+/**
+ * GlusterCoreUtil.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.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.gluster.storage.management.core.model.Disk;
+
+
+public class GlusterCoreUtil {
+ // Convert from Disk list to Qualified disk name list
+ public static final List<String> getQualifiedDiskNames(List<Disk> diskList) {
+ List<String> qualifiedDiskNames = new ArrayList<String>();
+ for (Disk disk : diskList) {
+ qualifiedDiskNames.add(disk.getQualifiedName());
+ }
+ return qualifiedDiskNames;
+ }
+}
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 45f4c436..8dc5837d 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
@@ -18,15 +18,24 @@
*******************************************************************************/
package com.gluster.storage.management.core.utils;
+import java.util.List;
+
public class StringUtil {
- public static boolean filterString(String sourceString,
- String filterString, boolean caseSensitive) {
- return caseSensitive ? sourceString.contains(filterString)
- : sourceString.toLowerCase().contains(
- filterString.toLowerCase());
+ public static boolean filterString(String sourceString, String filterString, boolean caseSensitive) {
+ return caseSensitive ? sourceString.contains(filterString) : sourceString.toLowerCase().contains(
+ filterString.toLowerCase());
}
-
+
public static String removeSpaces(String str) {
return str.replaceAll("\\s+", "");
}
+
+ public static String ListToString(List<String> list, String delimiter) {
+ StringBuilder output = new StringBuilder();
+ for(String element : list) {
+ output.append(element).append(delimiter);
+ }
+ String outputStr = output.toString();
+ return outputStr.substring(0, outputStr.length() - (delimiter.length()+1));
+ }
}