diff options
| author | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-03-28 06:58:51 -0700 |
|---|---|---|
| committer | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-03-28 06:58:51 -0700 |
| commit | bf531d097bc99db08bda4d1a1dec541c57c7933c (patch) | |
| tree | 253a3fc82d5bac3755fc7e32f8456879b69b9979 /com.gluster.storage.management.core | |
| parent | b27c5d68d3ffa47c92e0fcd7d0873ac2d6b8fca8 (diff) | |
Preparing src for migration to github
Diffstat (limited to 'com.gluster.storage.management.core')
49 files changed, 0 insertions, 3895 deletions
diff --git a/com.gluster.storage.management.core/.classpath b/com.gluster.storage.management.core/.classpath deleted file mode 100644 index b41cbcdb..00000000 --- a/com.gluster.storage.management.core/.classpath +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="junit"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/com.gluster.storage.management.core/.project b/com.gluster.storage.management.core/.project deleted file mode 100644 index 6c8fbb5c..00000000 --- a/com.gluster.storage.management.core/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>com.gluster.storage.management.core</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/com.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs b/com.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f22cedf1..00000000 --- a/com.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Dec 22 11:18:01 IST 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/com.gluster.storage.management.core/META-INF/MANIFEST.MF b/com.gluster.storage.management.core/META-INF/MANIFEST.MF deleted file mode 100644 index b5a2a830..00000000 --- a/com.gluster.storage.management.core/META-INF/MANIFEST.MF +++ /dev/null @@ -1,12 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Gluster Storage Platform Core -Bundle-SymbolicName: com.gluster.storage.management.core -Bundle-Version: 1.0.0 -Bundle-Vendor: GLUSTER -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Export-Package: com.gluster.storage.management.core.constants, - com.gluster.storage.management.core.exceptions, - com.gluster.storage.management.core.model, - com.gluster.storage.management.core.utils -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0" diff --git a/com.gluster.storage.management.core/build.properties b/com.gluster.storage.management.core/build.properties deleted file mode 100644 index 34d2e4d2..00000000 --- a/com.gluster.storage.management.core/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java b/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java deleted file mode 100644 index 8902ae8f..00000000 --- a/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * TestFileUtil.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 static org.junit.Assert.assertTrue; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStreamWriter; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class TestFileUtil { - private String testFileName; - private String fileContent; - private FileUtil fileUtil; - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - testFileName = "testFileUtil.txt"; - fileContent = "Testing FileUtil class."; - fileUtil = new FileUtil(); - - BufferedOutputStream outStream = new BufferedOutputStream(new FileOutputStream(testFileName)); - OutputStreamWriter writer = new OutputStreamWriter(outStream); - writer.write(fileContent); - writer.close(); - outStream.close(); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - File testFile = new File(testFileName); - testFile.delete(); - } - - /** - * Test method for {@link com.gluster.storage.management.core.utils.FileUtil#readFileAsString(java.io.File)}. - */ - @Test - public final void testReadFileAsString() { - String readContent = fileUtil.readFileAsString(new File(testFileName)); - assertTrue("File contents expected [" + fileContent + "], actual [" + readContent + "]", - readContent.equals(fileContent)); - } - - /** - * Test method for {@link com.gluster.storage.management.core.utils.FileUtil#loadResource(java.lang.String)}. - */ - @Test - public final void testLoadResource() { - InputStream inputStream = fileUtil.loadResource("test/test.txt"); - Assert.assertNotNull(inputStream); - } -} diff --git a/com.gluster.storage.management.core/junit/core.junit.launch b/com.gluster.storage.management.core/junit/core.junit.launch deleted file mode 100644 index 0bf6dc30..00000000 --- a/com.gluster.storage.management.core/junit/core.junit.launch +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.jdt.junit.launchconfig"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/com.gluster.storage.management.core"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="4"/> -</listAttribute> -<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.gluster.storage.management.core"/> -<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> -<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> -<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.gluster.storage.management.core"/> -</launchConfiguration> diff --git a/com.gluster.storage.management.core/junit/test/test.txt b/com.gluster.storage.management.core/junit/test/test.txt deleted file mode 100644 index 267ce144..00000000 --- a/com.gluster.storage.management.core/junit/test/test.txt +++ /dev/null @@ -1 +0,0 @@ -Test Resource
\ No newline at end of file diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/CoreConstants.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/CoreConstants.java deleted file mode 100644 index 177334bd..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/CoreConstants.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * 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.constants; - - -/** - * - */ -public class CoreConstants { - public static final String NEWLINE = System.getProperty("line.separator"); - public static final String FILE_SEPARATOR = System.getProperty("file.separator"); - public static final String ENCODING_UTF8 = "UTF-8"; -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java deleted file mode 100644 index fb40be8a..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * RESTConstants.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.constants; - -/** - * All constants related to the Gluster REST server and client - */ -public class RESTConstants { - // Volumes Resource - public static final String RESOURCE_PATH_VOLUMES = "/cluster/volumes"; - public static final String FORM_PARAM_OPERATION = "operation"; - public static final String FORM_PARAM_VALUE_START = "start"; - public static final String FORM_PARAM_VALUE_STOP = "stop"; - public static final String PATH_PARAM_VOLUME_NAME = "volumeName"; - public static final String SUBRESOURCE_DEFAULT_OPTIONS = "defaultoptions"; - - // Running tasks resource - public static final String RESOURCE_PATH_RUNNING_TASKS = "/cluster/runningtasks"; -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterRuntimeException.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterRuntimeException.java deleted file mode 100644 index e7e604fc..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterRuntimeException.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * 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.exceptions; - -public class GlusterRuntimeException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public GlusterRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public GlusterRuntimeException(String message) { - super(message); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AbstractResponse.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AbstractResponse.java deleted file mode 100644 index be552bdc..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AbstractResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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 AbstractResponse implements Response {
- private Status status;
-
- @Override
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-}
\ No newline at end of file diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java deleted file mode 100644 index 65d5ebea..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * 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 java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="cluster") -public class Cluster extends Entity { - List<GlusterServer> servers = new ArrayList<GlusterServer>(); - List<Server> discoveredServers = new ArrayList<Server>(); - List<Volume> volumes = new ArrayList<Volume>(); - List<RunningTask> runningTasks = new ArrayList<RunningTask>(); - - public Cluster() { - } - - public List<GlusterServer> getServers() { - return servers; - } - - public void addServer(GlusterServer server) { - servers.add(server); - } - - public void removeServer(GlusterServer server) { - servers.remove(server); - } - - public void addDiscoveredServer(Server server) { - discoveredServers.add(server); - } - - public void removeDiscoveredServer(Server server) { - discoveredServers.remove(server); - } - - public void setServers(List<GlusterServer> servers) { - this.servers = servers; - children.add(new EntityGroup<GlusterServer>("Servers", GlusterServer.class, this, servers)); - } - - public List<Server> getAutoDiscoveredServers() { - return discoveredServers; - } - - public void setAutoDiscoveredServers(List<Server> autoDiscoveredServers) { - this.discoveredServers = autoDiscoveredServers; - children.add(new EntityGroup<Server>("Discovered Servers", Server.class, this, autoDiscoveredServers)); - } - - public List<Volume> getVolumes() { - return volumes; - } - - public void setVolumes(List<Volume> volumes) { - this.volumes = volumes; - children.add(new EntityGroup<Volume>("Volumes", Volume.class, this, volumes)); - } - - public void addVolume(Volume volume) { - this.volumes.add(volume); - } - - public Cluster(String name, Entity parent) { - super(name, parent); - } - - public Cluster(String name, Entity parent, List<GlusterServer> servers, List<Volume> volumes) { - super(name, parent); - setServers(servers); - setVolumes(volumes); - } - - public List<RunningTask> getRunningTasks() { - return runningTasks; - } - - public void setRunningTasks(List<RunningTask> runningTasks) { - this.runningTasks = runningTasks; - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ClusterListener.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ClusterListener.java deleted file mode 100644 index ce2752a4..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ClusterListener.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * 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; - -/** - * Interface for a cluster listener. Every registered listener will be notified - * on various events happening on the cluster. - */ -public interface ClusterListener { - public void discoveredServerAdded(Server server); - - public void discoveredServerRemoved(Server server); - - public void serverAdded(GlusterServer server); - - public void serverRemoved(GlusterServer server); - - public void serverChanged(GlusterServer server, Event event); - - public void volumeAdded(Volume volume); - - public void volumeRemoved(Volume volume); - - public void volumeChanged(Volume volume, Event event); - - public void volumeCreated(Volume volume); -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ConnectionDetails.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ConnectionDetails.java deleted file mode 100644 index ccf8fecf..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ConnectionDetails.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * 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 ConnectionDetails { - private String userId, password; - - public ConnectionDetails() { - - } - - public ConnectionDetails(String userId, String password) { - this.userId = userId; - this.password = password; - } - - public String getUserId() { - return userId; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/DefaultClusterListener.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/DefaultClusterListener.java deleted file mode 100644 index 1a39a014..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/DefaultClusterListener.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * 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; - -/** - * Default listener - doesn't do anything. Sub-class and override the method for - * the event you want to handle. - */ -public class DefaultClusterListener implements ClusterListener { - - @Override - public void serverAdded(GlusterServer server) { - clusterChanged(); - } - - @Override - public void serverRemoved(GlusterServer server) { - clusterChanged(); - } - - @Override - public void serverChanged(GlusterServer server, Event event) { - clusterChanged(); - } - - @Override - public void volumeAdded(Volume volume) { - clusterChanged(); - } - - @Override - public void volumeRemoved(Volume volume) { - clusterChanged(); - } - - @Override - public void volumeChanged(Volume volume, Event event) { - clusterChanged(); - } - - @Override - public void discoveredServerAdded(Server server) { - clusterChanged(); - } - - @Override - public void discoveredServerRemoved(Server server) { - clusterChanged(); - } - - @Override - public void volumeCreated(Volume volume) { - clusterChanged(); - } - - /** - * This method is called by every other event method. Thus, if a view/listener is interested in performing the same - * task on any change happening in the cluster data model, it can simply override this method and implement the - * logic. e.g. A view may simply refresh its tree/table viewer whenever the cluster data model changes. - */ - public void clusterChanged() { - - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java deleted file mode 100644 index 9924d596..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * 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 javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement(name="Disk") -public class Disk extends Entity { - public enum DISK_STATUS { - READY, UNINITIALIZED, INITIALIZING, OFFLINE - }; - - private String[] DISK_STATUS_STR = { "Ready", "Uninitialized", "Initializing", "Offline" }; - - private String serverName; - private Double space; - private Double spaceInUse; - private DISK_STATUS status; - - public Disk() { - - } - - public Double getSpace() { - return space; - } - - public void setSpace(Double space) { - this.space = space; - } - - public boolean isUninitialized() { - return getStatus() == DISK_STATUS.UNINITIALIZED; - } - - public boolean isOffline() { - return getStatus() == DISK_STATUS.OFFLINE; - } - - public boolean isReady() { - return getStatus() == DISK_STATUS.READY; - } - - public DISK_STATUS getStatus() { - return status; - } - - public String getStatusStr() { - return DISK_STATUS_STR[getStatus().ordinal()]; - } - - public void setStatus(DISK_STATUS status) { - this.status = status; - } - - public Double getSpaceInUse() { - return spaceInUse; - } - - public void setSpaceInUse(Double spaceInUse) { - this.spaceInUse = spaceInUse; - } - - public String getServerName() { - return serverName; - } - - public void setServerName(String serverName) { - this.serverName = serverName; - } - - public Disk(Server server, String name, Double space, Double spaceInUse, DISK_STATUS status) { - super(name, server); - setServerName(server != null ? server.getName() : ""); - setSpace(space); - setSpaceInUse(spaceInUse); - setStatus(status); - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getServerName() + getName() + getStatusStr(), filterString, caseSensitive); - } - - public String getQualifiedName() { - return getServerName() + ":" + getName(); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Entity.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Entity.java deleted file mode 100644 index e721d052..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Entity.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * 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 java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import org.eclipse.core.runtime.PlatformObject; - -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement -public class Entity extends PlatformObject implements Filterable { - private static final long serialVersionUID = 1L; - - protected String name; - protected List<Entity> children = new ArrayList<Entity>(); - private Entity parent; - - public Entity() { - - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @XmlTransient - public Entity getParent() { - return parent; - } - - public void setParent(Entity parent) { - this.parent = parent; - } - - public List<? extends Entity> getChildren() { - return children; - } - - public void setChildren(List<Entity> children) { - this.children = children; - } - - public Entity(String name, Entity parent) { - this.name = name; - this.parent = parent; - } - - public Entity(String name, Entity parent, List<Entity> children) { - this.name = name; - this.parent = parent; - this.children = children; - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getName(), filterString, caseSensitive); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/EntityGroup.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/EntityGroup.java deleted file mode 100644 index 0fc0f507..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/EntityGroup.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * 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 java.util.List; - -public class EntityGroup<T> extends Entity { - private Class<? extends Entity> type; - - public EntityGroup(String name, Class<? extends Entity> type, Cluster cluster) { - this(name, type, cluster, null); - } - - public EntityGroup(String name, Class<? extends Entity> type, Cluster cluster, List<T> entities) { - super(name, cluster, (List<Entity>)entities); - this.type = type; - } - - public List<? extends Entity> getEntities() { - return children; - } - - public void setEntities(List<T> entities) { - children = (List<Entity>)entities; - } - - public Class<? extends Entity> getEntityType() { - return type; - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java deleted file mode 100644 index 65501a2b..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * 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 Event { - public enum EVENT_TYPE { - DISK_ADDED, - DISK_REMOVED, - NETWORK_INTERFACE_ADDED, - NETWORK_INTERFACE_REMOVED, - VOLUME_STATUS_CHANGED - } - - private EVENT_TYPE eventType; - private Object eventData; - - public Event(EVENT_TYPE eventType, Object eventData) { - this.eventType = eventType; - this.eventData = eventData; - } - - public EVENT_TYPE getEventType() { - return eventType; - } - - public void setEventType(EVENT_TYPE eventType) { - this.eventType = eventType; - } - - public Object getEventData() { - return eventData; - } - - public void setEventData(Object eventData) { - this.eventData = eventData; - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Filterable.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Filterable.java deleted file mode 100644 index 9a2ed405..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Filterable.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * 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; - -/** - * By default, the {@link EntityViewerFilter} filters the objects by parsing the - * output of {@link Object#toString()} with the filter string. Classes that need - * specific filtering logic can implement this interface. The default logic will - * then be overridden by the method {@link Filterable#filter(String)}. - */ -public interface Filterable { - /** - * @param filterString - * String to be used for filtering - * @param caseSensitive - * Flag indicating whether the filtering should be case sensitive - * @return true if the object can be selected using the filter string, else - * false - */ - public boolean filter(String filterString, boolean caseSensitive); -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GenericResponse.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GenericResponse.java deleted file mode 100644 index efeed34b..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GenericResponse.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * GenericServerResponse.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 javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "response") -public class GenericResponse<T> extends AbstractResponse { - private T data; - private Status status; - - @Override - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public GenericResponse(Status status, T data) { - setStatus(status); - this.data = data; - } - - public GenericResponse() { - } - - @Override - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } - -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java deleted file mode 100644 index 612cae31..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * 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 java.util.ArrayList; -import java.util.List; - -public class GlusterDataModel extends Entity { - public GlusterDataModel(String name, List<Cluster> clusters) { - super(name, null); - children.addAll(clusters); - } - - public GlusterDataModel(String name) { - this(name, new ArrayList<Cluster>()); - } - - public void setClusters(List<Cluster> clusters) { - children.clear(); - children.addAll(clusters); - } - - public void addCluster(Cluster cluster) { - children.add(cluster); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java deleted file mode 100644 index 11d31553..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java +++ /dev/null @@ -1,283 +0,0 @@ -/******************************************************************************* - * 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 java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -import com.gluster.storage.management.core.model.Disk.DISK_STATUS; -import com.gluster.storage.management.core.model.GlusterServer.SERVER_STATUS; -import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; - -public class GlusterDummyModel { - // private Server discoveredServer1, discoveredServer2, discoveredServer3, discoveredServer4, discoveredServer5; - private GlusterServer server1, server2, server3, server4, server5; - private Volume volume1, volume2, volume3, volume4, volume5; - private Disk s1da, s1db, s2da, s2db, s2dc, s2dd, s3da, s4da, s5da, s5db; - private static List<LogMessage> logMessages = new ArrayList<LogMessage>(); - private static GlusterDummyModel instance = new GlusterDummyModel(); - private GlusterDataModel model; - - private GlusterDummyModel() { - model = initializeModel(); - } - - public GlusterDataModel getModel() { - return model; - } - - public static GlusterDummyModel getInstance() { - return instance; - } - - // Renamed preferredInterfaceName to interfaceName - private GlusterServer addGlusterServer(List<GlusterServer> servers, Entity parent, String name, - SERVER_STATUS status, String interfaceName, int numOfCPUs, double cpuUsage, double totalMemory, - double memoryInUse) { - GlusterServer glusterServer = new GlusterServer(name, parent, status, numOfCPUs, cpuUsage, totalMemory, - memoryInUse); - NetworkInterface networkInterface = addNetworkInterface(glusterServer, interfaceName); // Renamed preferredInterfaceName to interfaceName - // glusterServer.setPreferredNetworkInterface(networkInterface); - - servers.add(glusterServer); - return glusterServer; - } - - private NetworkInterface addNetworkInterface(Server server, String interfaceName) { - NetworkInterface networkInterface = new NetworkInterface(interfaceName, server, "192.168.1." - + Math.round(Math.random() * 255), "255.255.255.0", "192.168.1.1"); - server.setNetworkInterfaces(Arrays.asList(new NetworkInterface[] { networkInterface })); - return networkInterface; - } - - 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", totalDiskSpace, diskSpaceInUse, DISK_STATUS.READY)); - addNetworkInterface(server, "eth0"); - - servers.add(server); - } - - private GlusterDataModel initializeModel() { - // Create the dummy data model for demo - GlusterDataModel model = new GlusterDataModel("Clusters"); - Cluster cluster = new Cluster("Home", model); - - initializeGlusterServers(cluster); - initializeVolumes(cluster); - initializeAutoDiscoveredServers(cluster); - initializeDisks(); - addDisksToServers(); - addDisksToVolumes(); - addVolumeOptions(); - - createDummyLogMessages(); - - model.addCluster(cluster); - return model; - } - - private void addVolumeOptions() { - for (Volume vol : new Volume[] { volume1, volume2, volume3, volume4, volume5 }) { - for (int i = 1; i <= 5; i++) { - String key = vol.getName() + "key" + i; - String value = vol.getName() + "value" + i; - vol.setOption(key, value); - } - } - } - - private Volume addVolume(List<Volume> volumes, String name, Cluster cluster, VOLUME_TYPE volumeType, - TRANSPORT_TYPE transportType, VOLUME_STATUS status) { - Volume volume = new Volume(name, cluster, volumeType, transportType, status); - volumes.add(volume); - - return volume; - } - - private void initializeVolumes(Cluster cluster) { - List<Volume> volumes = new ArrayList<Volume>(); - - volume1 = addVolume(volumes, "Volume1", cluster, VOLUME_TYPE.PLAIN_DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.ONLINE); - - volume2 = addVolume(volumes, "Volume2", cluster, VOLUME_TYPE.PLAIN_DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.ONLINE); - - volume3 = addVolume(volumes, "Volume3", cluster, VOLUME_TYPE.DISTRIBUTED_MIRROR, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.OFFLINE); - volume3.setReplicaCount(2); - - volume4 = addVolume(volumes, "Volume4", cluster, VOLUME_TYPE.PLAIN_DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.ONLINE); - - volume5 = addVolume(volumes, "Volume5", cluster, VOLUME_TYPE.DISTRIBUTED_STRIPE, TRANSPORT_TYPE.INFINIBAND, - VOLUME_STATUS.OFFLINE); - volume5.setStripeCount(3); - - cluster.setVolumes(volumes); - } - - private void initializeDisks() { - s1da = new Disk(server1, "sda", 100d, 80d, DISK_STATUS.READY); - s1db = new Disk(server1, "sdb", 100d, 67.83, DISK_STATUS.READY); - - s2da = new Disk(server2, "sda", 200d, 157.12, DISK_STATUS.READY); - s2db = new Disk(server2, "sdb", 200d, 182.27, DISK_STATUS.READY); - s2dc = new Disk(server2, "sdc", 200d, -1d, DISK_STATUS.UNINITIALIZED); - s2dd = new Disk(server2, "sdd", 200d, 124.89, DISK_STATUS.READY); - - s3da = new Disk(server3, "NA", -1d, -1d, DISK_STATUS.OFFLINE); // disk name unavailable since server is offline - - s4da = new Disk(server4, "sda", 100d, 85.39, DISK_STATUS.READY); - - s5da = new Disk(server5, "sda", 100d, 92.83, DISK_STATUS.READY); - s5db = new Disk(server5, "sdb", 200d, 185.69, DISK_STATUS.READY); - } - - private void addDisksToServers() { - server1.addDisk(s1da); - server1.addDisk(s1db); - - server2.addDisk(s2da); - server2.addDisk(s2db); - server2.addDisk(s2dc); - server2.addDisk(s2dd); - - // server3.addDisk(s3da); - - server4.addDisk(s4da); - - server5.addDisk(s5da); - server5.addDisk(s5db); - } - - private void addDisksToVolumes() { - volume1.addDisk(s1da); - - volume2.addDisk(s2da); - volume2.addDisk(s1db); - volume2.addDisk(s3da); - volume2.addDisk(s4da); - - volume3.addDisk(s2db); - volume3.addDisk(s4da); - volume3.addDisk(s5da); - - volume4.addDisk(s1da); - volume4.addDisk(s3da); - volume4.addDisk(s4da); - volume4.addDisk(s5db); - - volume5.addDisk(s2da); - volume5.addDisk(s5db); - } - - private void initializeGlusterServers(Cluster cluster) { - List<GlusterServer> servers = new ArrayList<GlusterServer>(); - server1 = addGlusterServer(servers, cluster, "Server1", SERVER_STATUS.ONLINE, "eth0", 4, 56.3, 16, 8.4); - server2 = addGlusterServer(servers, cluster, "Server2", SERVER_STATUS.ONLINE, "eth1", 8, 41.92, 32, 18.76); - server3 = addGlusterServer(servers, cluster, "Server3", SERVER_STATUS.OFFLINE, "eth0", -1, -1, -1, -1); - server4 = addGlusterServer(servers, cluster, "Server4", SERVER_STATUS.ONLINE, "eth0", 1, 92.83, 4, 3.18); - server5 = addGlusterServer(servers, cluster, "Server5", SERVER_STATUS.ONLINE, "inf0", 2, 87.24, 8, 7.23); - - cluster.setServers(servers); - } - - private void initializeAutoDiscoveredServers(Cluster cluster) { - List<Server> servers = new ArrayList<Server>(); - addDiscoveredServer(servers, cluster, "ADServer1", 4, 56.3, 16, 8.4, 200, 147.83); - addDiscoveredServer(servers, cluster, "ADServer2", 8, 41.92, 32, 18.76, 800, 464.28); - addDiscoveredServer(servers, cluster, "ADServer3", 2, 84.28, 2, 1.41, 120, 69.93); - addDiscoveredServer(servers, cluster, "ADServer4", 1, 92.83, 4, 3.18, 100, 85.39); - addDiscoveredServer(servers, cluster, "ADServer5", 2, 87.24, 8, 7.23, 250, 238.52); - cluster.setAutoDiscoveredServers(servers); - } - - private void addMessages(List<LogMessage> messages, Disk disk, String severity, int count) { - for (int i = 1; i <= count; i++) { - String message = severity + "message" + i; - messages.add(new LogMessage(new Date(), disk, severity, message)); - } - } - - private void addMessagesForDisk(List<LogMessage> logMessages, Disk disk) { - addMessages(logMessages, disk, "SEVERE", 5); - addMessages(logMessages, disk, "WARNING", 5); - addMessages(logMessages, disk, "DEBUG", 5); - addMessages(logMessages, disk, "INFO", 5); - } - - public List<LogMessage> createDummyLogMessages() { - addMessagesForDisk(logMessages, s1da); - addMessagesForDisk(logMessages, s1db); - addMessagesForDisk(logMessages, s2da); - addMessagesForDisk(logMessages, s2db); - addMessagesForDisk(logMessages, s2dc); - addMessagesForDisk(logMessages, s2dd); - addMessagesForDisk(logMessages, s4da); - addMessagesForDisk(logMessages, s5da); - addMessagesForDisk(logMessages, s5db); - return logMessages; - } - - public static List<LogMessage> getDummyLogMessages() { - return logMessages; - } - - public List<Disk> getReadyDisksOfVolume(Volume volume) { - List<Disk> disks = new ArrayList<Disk>(); - for (Disk disk : volume.getDisks()) { - if (disk.isReady()) { - disks.add(disk); - } - } - return disks; - } - - public List<Disk> getReadyDisksOfAllVolumes() { - List<Disk> disks = new ArrayList<Disk>(); - for (Volume volume : ((Cluster) model.getChildren().get(0)).getVolumes()) { - disks.addAll(getReadyDisksOfVolume(volume)); - } - return disks; - } - - public List<Disk> getReadyDisksOfAllServers() { - return getReadyDisksOfAllServersExcluding(new ArrayList<Disk>()); - } - - public List<Disk> getReadyDisksOfAllServersExcluding(List<Disk> excludeDisks) { - List<Disk> disks = new ArrayList<Disk>(); - - for (Server server : ((Cluster) model.getChildren().get(0)).getServers()) { - for (Disk disk : server.getDisks()) { - if (disk.isReady() && !excludeDisks.contains(disk)) { - disks.add(disk); - } - } - } - return disks; - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java deleted file mode 100644 index fd4e58c9..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * 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 javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement(name = "glusterServer") -public class GlusterServer extends Server { - public enum SERVER_STATUS { - ONLINE, OFFLINE - }; - - private static final String[] STATUS_STR = new String[] { "Online", "Offline" }; - - private String uuid; - private SERVER_STATUS status; - // private NetworkInterface preferredNetworkInterface; - private Cluster cluster; - - public GlusterServer() { - } - - public GlusterServer(String name) { - super(name); - } - - public GlusterServer(String name, Entity parent, SERVER_STATUS status, int numOfCPUs, double cpuUsage, - double totalMemory, double memoryInUse) { - super(name, parent, numOfCPUs, cpuUsage, totalMemory, memoryInUse); - setStatus(status); - } - - public GlusterServer(String name, Entity parent, SERVER_STATUS status, int numOfCPUs, double cpuUsage, - double totalMemory, double memoryInUse, Cluster cluster) { - this(name, parent, status, numOfCPUs, cpuUsage, totalMemory, memoryInUse); - setCluster(cluster); - } - - public String getStatusStr() { - return STATUS_STR[getStatus().ordinal()]; - } - - public SERVER_STATUS getStatus() { - return status; - } - - public void setStatus(SERVER_STATUS status) { - this.status = status; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - -// public NetworkInterface getPreferredNetworkInterface() { -// return preferredNetworkInterface; -// } -// -// public void setPreferredNetworkInterface(NetworkInterface preferredNetworkInterface) { -// this.preferredNetworkInterface = preferredNetworkInterface; -// preferredNetworkInterface.setPreferred(true); -// } - - - @XmlTransient - public Cluster getCluster() { - return cluster; - } - - public void setCluster(Cluster cluster) { - this.cluster = cluster; - } - - /** - * Filter matches if any of the properties name, status and primary/secondary/third - * DNS contains the filter string - */ - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getName() + getStatusStr(), filterString, caseSensitive); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServerListResponse.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServerListResponse.java deleted file mode 100644 index 479dcc09..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServerListResponse.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * GlusterServerListResponse.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 java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -/** - * - */ -@XmlRootElement(name = "response") -public class GlusterServerListResponse extends AbstractResponse { - private List<GlusterServer> servers = new ArrayList<GlusterServer>(); - - public GlusterServerListResponse() { - } - - public GlusterServerListResponse(Status status, List<GlusterServer> servers) { - setStatus(status); - setServers(servers); - } - - @XmlElementWrapper(name = "servers") - @XmlElement(name = "server", type=GlusterServer.class) - public List<GlusterServer> getServers() { - return servers; - } - - /** - * @param servers - * the servers to set - */ - public void setServers(List<GlusterServer> servers) { - this.servers = servers; - } - - /* - * (non-Javadoc) - * - * @see com.gluster.storage.management.core.model.Response#getData() - */ - @Override - @XmlTransient - public List<GlusterServer> getData() { - return getServers(); - } -} - diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServerResponse.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServerResponse.java deleted file mode 100644 index e00b8288..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServerResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -@XmlRootElement(name = "response") -public class GlusterServerResponse extends AbstractResponse { - private GlusterServer glusterServer; - - public GlusterServerResponse() { - } - - public GlusterServerResponse(Status status, GlusterServer server) { - setStatus(status); - setGlusterServer(server); - } - - public GlusterServer getGlusterServer() { - return glusterServer; - } - - public void setGlusterServer(GlusterServer glusterServer) { - this.glusterServer = glusterServer; - } - - @XmlTransient - @Override - public GlusterServer getData() { - return getGlusterServer(); - } - -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/LogMessage.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/LogMessage.java deleted file mode 100644 index cc3aa043..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/LogMessage.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * 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 java.util.Date; - -import com.gluster.storage.management.core.utils.StringUtil; - -public class LogMessage implements Filterable { - private Date timestamp; - private Disk disk; - private String severity; - private String message; - - public Date getTimestamp() { - return timestamp; - } - - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - public Disk getDisk() { - return disk; - } - - public void setDisk(Disk disk) { - this.disk = disk; - } - - public String getSeverity() { - return severity; - } - - public void setSeverity(String severity) { - this.severity = severity; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public LogMessage(Date timestamp, Disk disk, String severity, String message) { - setTimestamp(timestamp); - setDisk(disk); - setSeverity(severity); - setMessage(message); - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getSeverity() + getTimestamp() + getDisk().getServerName() - + getDisk().getQualifiedName() + getMessage(), filterString, caseSensitive); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/NetworkInterface.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/NetworkInterface.java deleted file mode 100644 index 882dfe09..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/NetworkInterface.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * 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 javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="networkInterface") -public class NetworkInterface extends Entity { - private String ipAddress; - private String netMask; - private String defaultGateway; -// private boolean isPreferred; - - public NetworkInterface() { - - } - -// public boolean isPreferred() { -// return isPreferred; -// } -// -// public void setPreferred(boolean isPreferred) { -// this.isPreferred = isPreferred; -// } - - public String getIpAddress() { - return ipAddress; - } - - public void setIpAddress(String ipAddress) { - this.ipAddress = ipAddress; - } - - public String getNetMask() { - return netMask; - } - - public void setNetMask(String netMask) { - this.netMask = netMask; - } - - public String getDefaultGateway() { - return defaultGateway; - } - - public void setDefaultGateway(String defaultGateway) { - this.defaultGateway = defaultGateway; - } - - public NetworkInterface(String name, Entity parent, String ipAddress, String netMask, String defaultGateway) { - super(name, parent); - setIpAddress(ipAddress); - setNetMask(netMask); - setDefaultGateway(defaultGateway); - } - -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Response.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Response.java deleted file mode 100644 index 96ea8497..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Response.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * 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;
-
-/**
- * Interface for server response. Any request handled by the Gluster Management
- * Server will result in a response that must be an instance of a class
- * implementing this interface.
- */
-public interface Response<T> { - /**
- * @return Status of request processing
- */
- public Status getStatus();
-
- /**
- * @return Data associated with the response. e.g. A "discover servers"
- * request will return the list of discovered servers.
- */
- public T getData();
-}
diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java deleted file mode 100644 index 1a9d63f6..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * 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 javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class RunningTask { - - protected String id; - protected String type; // FormatDisk, MigrateDisk, VolumeRebalance - protected Object reference; - protected String description; - protected RunningTaskStatus status; // TODO redefine - - public RunningTask() { - - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Object getReference() { - return reference; - } - - public void setReference(Object reference) { - this.reference = reference; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public RunningTaskStatus getStatus() { - return status; - } - - public void setStatus(RunningTaskStatus status) { - this.status = status; - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTaskListResponse.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTaskListResponse.java deleted file mode 100644 index 79949c90..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTaskListResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "response") -public class RunningTaskListResponse extends AbstractResponse { - private List<RunningTask> runningTasks = new ArrayList<RunningTask>(); - - public RunningTaskListResponse() { - - } - - - public RunningTaskListResponse(Status status, List<RunningTask> runningTasks) { - setStatus(status); - setRunningTasks(runningTasks); - } - - @XmlElementWrapper(name = "runningTasks") - @XmlElement(name = "runningTask", type=RunningTask.class) - public List<RunningTask> getRunningTasks() { - return runningTasks; - } - - /** - * @param runningTasks - * the runningTasks to set - */ - public void setRunningTasks(List<RunningTask> runningTasks) { - this.runningTasks = runningTasks; - } - - @Override - public Object getData() { - return getRunningTasks(); - } - -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTaskStatus.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTaskStatus.java deleted file mode 100644 index 7ffeb4b8..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTaskStatus.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.gluster.storage.management.core.model; - -public class RunningTaskStatus extends Status { - - private String status; - private boolean isPercentageSupported; - private float percentCompleted; - private String description; - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public boolean isPercentageSupported() { - return isPercentageSupported; - } - - public void setPercentageSupported(boolean isPercentageSupported) { - this.isPercentageSupported = isPercentageSupported; - } - - public float getPercentCompleted() { - return percentCompleted; - } - - public void getPercentCompleted(float percentCompleted) { - this.percentCompleted = percentCompleted; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDescription() { - return description; - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Server.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Server.java deleted file mode 100644 index bc0c42bc..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Server.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * 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 java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement(name = "server") -public class Server extends Entity { - private List<NetworkInterface> networkInterfaces = new ArrayList<NetworkInterface>(); - private int numOfCPUs; - private double cpuUsage; - private double totalMemory; - private double memoryInUse; - private double totalDiskSpace = 0; - private double diskSpaceInUse = 0; - private List<Disk> disks = new ArrayList<Disk>(); - - public Server() { - - } - - public Server(String name) { - super(name, null); - } - - public Server(String name, Entity parent, int numOfCPUs, double cpuUsage, double totalMemory, double memoryInUse) { - super(name, parent); - setNumOfCPUs(numOfCPUs); - setCpuUsage(cpuUsage); - setTotalMemory(totalMemory); - setMemoryInUse(memoryInUse); - } - - public int getNumOfCPUs() { - return numOfCPUs; - } - - public void setNumOfCPUs(int numOfCPUs) { - this.numOfCPUs = numOfCPUs; - } - - public double getCpuUsage() { - return cpuUsage; - } - - public void setCpuUsage(double cpuUsage) { - this.cpuUsage = cpuUsage; - } - - public double getTotalMemory() { - return totalMemory; - } - - public void setTotalMemory(double totalMemory) { - this.totalMemory = totalMemory; - } - - public double getMemoryInUse() { - return memoryInUse; - } - - public void setMemoryInUse(double memoryInUse) { - this.memoryInUse = memoryInUse; - } - - public double getTotalDiskSpace() { - return totalDiskSpace; - } - - /** - * Total disk space is automatically calculated, and hence this method should never be called. It is required only - * to make sure that the element "totalDiskSpace" gets added to the XML tag when jersey converts the server object - * to XML for sending to client. - */ - public void setTotalDiskSpace(double totalDiskSpace) { - this.totalDiskSpace = totalDiskSpace; - } - - public double getDiskSpaceInUse() { - return diskSpaceInUse; - } - - @XmlElementWrapper(name = "networkInterfaces") - @XmlElement(name = "networkInterface", type = NetworkInterface.class) - public List<NetworkInterface> getNetworkInterfaces() { - return networkInterfaces; - } - - public void setNetworkInterfaces(List<NetworkInterface> networkInterfaces) { - this.networkInterfaces = networkInterfaces; - } - - @XmlElementWrapper(name = "disks") - @XmlElement(name = "disk", type = Disk.class) - public List<Disk> getDisks() { - return disks; - } - - public void addNetworkInterface(NetworkInterface networkInterface) { - networkInterfaces.add(networkInterface); - } - - public void addDisk(Disk disk) { - if (disks.add(disk)) { - totalDiskSpace += disk.getSpace(); - diskSpaceInUse += disk.getSpaceInUse(); - } - } - - public void addDisks(List<Disk> disks) { - for (Disk disk : disks) { - addDisk(disk); - } - } - - public void removeDisk(Disk disk) { - if (disks.remove(disk)) { - totalDiskSpace -= disk.getSpace(); - diskSpaceInUse -= disk.getSpaceInUse(); - } - } - - public void removeAllDisks() { - disks.clear(); - totalDiskSpace = 0; - diskSpaceInUse = 0; - } - - public void setDisks(List<Disk> disks) { - removeAllDisks(); - addDisks(disks); - } - - public int getNumOfDisks() { - return disks.size(); - } - - public String getIpAddressesAsString() { - String ipAddresses = ""; - for (NetworkInterface networkInterface : getNetworkInterfaces()) { - String ipAddr = networkInterface.getIpAddress(); - ipAddresses += (ipAddresses.isEmpty() ? ipAddr : ", " + ipAddr); - } - return ipAddresses; - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getName() + getIpAddressesAsString(), filterString, caseSensitive); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerListResponse.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerListResponse.java deleted file mode 100644 index 56f33992..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerListResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * 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 java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -@XmlRootElement(name = "response") -public class ServerListResponse extends AbstractResponse { - private List<Server> servers = new ArrayList<Server>(); - - public ServerListResponse() { - } - - public ServerListResponse(Status status, List<Server> servers) { - setStatus(status); - setServers(servers); - } - - @XmlElementWrapper(name = "servers") - @XmlElement(name = "server", type=Server.class) - public List<Server> getServers() { - return servers; - } - - /** - * @param servers - * the servers to set - */ - public void setServers(List<Server> servers) { - this.servers = servers; - } - - /* - * (non-Javadoc) - * - * @see com.gluster.storage.management.core.model.Response#getData() - */ - @Override - @XmlTransient - public List<Server> getData() { - return getServers(); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java deleted file mode 100644 index 06d6efe1..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * 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 javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import com.gluster.storage.management.core.utils.ProcessResult; - -@XmlRootElement(name = "status") -public class Status { - public static final int STATUS_CODE_SUCCESS = 0; - public static final int STATUS_CODE_FAILURE = 1; - public static final int STATUS_CODE_RUNNING = 2; - public static final Status STATUS_SUCCESS = new Status(STATUS_CODE_SUCCESS, "Success"); - public static final Status STATUS_FAILURE = new Status(STATUS_CODE_FAILURE, "Failure"); - - // public static final Status - - private Integer code; - private String message; - - public Status() { - } - - public boolean isSuccess() { - return code == STATUS_CODE_SUCCESS; - } - - public Status(Integer code, String message) { - this.code = code; - this.message = message; - } - - public Status(ProcessResult result) { - this.code = result.getExitValue(); - this.message = result.getOutput(); - } - - @XmlElement(name = "code", type = Integer.class) - public Integer getCode() { - return code; - } - - public void setCode(Integer executionStatus) { - this.code = executionStatus; - } - - @XmlElement - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return (isSuccess() ? "Success" : "Failure [" + getCode() + "]") + ": " + getMessage(); - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StringListResponse.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StringListResponse.java deleted file mode 100644 index 3304692d..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StringListResponse.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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 java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "response") -public class StringListResponse extends AbstractResponse { - private List<String> data = new ArrayList<String>(); - - public StringListResponse() { - } - - public StringListResponse(List<String> data) { - this.data = data; - } - - @Override - @XmlElementWrapper(name = "list") - @XmlElement(name = "value", type = String.class) - public List<String> getData() { - return data; - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/User.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/User.java deleted file mode 100644 index da92ca14..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/User.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * 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 javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class User { - private String userId; - private String password; - - public String getUserId() { - return userId; - } - public void setUserId(String userId) { - this.userId = userId; - } - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java deleted file mode 100644 index a7e498c4..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************* - * 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 java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import com.gluster.storage.management.core.model.Disk.DISK_STATUS; -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement -public class Volume extends Entity { - public enum VOLUME_STATUS { - ONLINE, OFFLINE - }; - - public enum VOLUME_TYPE { - PLAIN_DISTRIBUTE, DISTRIBUTED_MIRROR, DISTRIBUTED_STRIPE - }; - - public enum TRANSPORT_TYPE { - ETHERNET, INFINIBAND - }; - - public enum NAS_PROTOCOL { - GLUSTERFS, NFS - }; - - private static final String[] VOLUME_TYPE_STR = new String[] { "Plain Distribute", "Distributed Mirror", - "Distributed Stripe" }; - private static final String[] TRANSPORT_TYPE_STR = new String[] { "Ethernet", "Infiniband" }; - private static final String[] STATUS_STR = new String[] { "Online", "Offline" }; - private static final String[] NAS_PROTOCOL_STR = new String[] { "Gluster", "NFS" }; - - private Cluster cluster; - private VOLUME_TYPE volumeType; - private TRANSPORT_TYPE transportType; - private VOLUME_STATUS status; - private int replicaCount; - private int stripeCount; - private Map<String, String> options = new LinkedHashMap<String, String>(); - - private double totalDiskSpace = 0; - private List<Disk> disks = new ArrayList<Disk>(); - - public Volume() { - } - - // GlusterFS export is always enabled - private Set<NAS_PROTOCOL> nasProtocols = new LinkedHashSet<NAS_PROTOCOL>( - Arrays.asList(new NAS_PROTOCOL[] { NAS_PROTOCOL.GLUSTERFS })); - - private String accessControlList = "*"; - - public String getVolumeTypeStr() { - return getVolumeTypeStr(getVolumeType()); - } - - public static String getVolumeTypeStr(VOLUME_TYPE volumeType) { - return VOLUME_TYPE_STR[volumeType.ordinal()]; - } - - public String getTransportTypeStr() { - return TRANSPORT_TYPE_STR[getTransportType().ordinal()]; - } - - public String getStatusStr() { - return STATUS_STR[getStatus().ordinal()]; - } - - public int getNumOfDisks() { - return disks.size(); - } - - public VOLUME_TYPE getVolumeType() { - return volumeType; - } - - public void setVolumeType(VOLUME_TYPE volumeType) { - this.volumeType = volumeType; - } - - public TRANSPORT_TYPE getTransportType() { - return transportType; - } - - public void setTransportType(TRANSPORT_TYPE transportType) { - this.transportType = transportType; - } - - public VOLUME_STATUS getStatus() { - return status; - } - - public int getReplicaCount() { - return replicaCount; - } - - public void setReplicaCount(int replicaCount) { - this.replicaCount = replicaCount; - } - - public int getStripeCount() { - return stripeCount; - } - - public void setStripeCount(int stripeCount) { - this.stripeCount = stripeCount; - } - - public void setStatus(VOLUME_STATUS status) { - this.status = status; - } - - @XmlTransient - public Cluster getCluster() { - return cluster; - } - - public void setCluster(Cluster cluster) { - this.cluster = cluster; - } - - public Set<NAS_PROTOCOL> getNASProtocols() { - return nasProtocols; - } - - public void setNASProtocols(Set<NAS_PROTOCOL> nasProtocols) { - this.nasProtocols = nasProtocols; - } - - public String getNASProtocolsStr() { - String protocolsStr = ""; - for (NAS_PROTOCOL protocol : nasProtocols) { - String protocolStr = NAS_PROTOCOL_STR[protocol.ordinal()]; - protocolsStr += (protocolsStr.isEmpty() ? protocolStr : ", " + protocolStr); - } - return protocolsStr; - } - - public String getAccessControlList() { - return accessControlList; - } - - public void setAccessControlList(String accessControlList) { - this.accessControlList = accessControlList; - } - - public Map<String, String> getOptions() { - return options; - } - - public void setOption(String key, String value) { - options.put(key, value); - } - - public void setOptions(Map<String, String> options) { - this.options = options; - } - - public double getTotalDiskSpace() { - return totalDiskSpace; - } - - public List<Disk> getDisks() { - return disks; - } - - public void addDisk(Disk disk) { - if (disks.add(disk) && disk.getStatus() != DISK_STATUS.OFFLINE) { - totalDiskSpace += disk.getSpace(); - } - } - - public void addDisks(List<Disk> disks) { - for (Disk disk : disks) { - addDisk(disk); - } - } - - public void removeDisk(Disk disk) { - if (disks.remove(disk)) { - totalDiskSpace -= disk.getSpace(); - } - } - - public void removeAllDisks() { - disks.clear(); - totalDiskSpace = 0; - } - - public void setDisks(List<Disk> disks) { - removeAllDisks(); - addDisks(disks); - } - - public void enableNFS() { - nasProtocols.add(NAS_PROTOCOL.NFS); - } - - public void disableNFS() { - nasProtocols.remove(NAS_PROTOCOL.NFS); - } - - public Volume(String name, Entity parent, VOLUME_TYPE volumeType, TRANSPORT_TYPE transportType, VOLUME_STATUS status) { - super(name, parent); - setVolumeType(volumeType); - setTransportType(transportType); - setStatus(status); - } - - public Volume(String name, Entity parent, Cluster cluster, VOLUME_TYPE volumeType, TRANSPORT_TYPE transportType, - VOLUME_STATUS status) { - this(name, parent, volumeType, transportType, status); - - setCluster(cluster); - } - - /** - * Filter matches if any of the properties name, volume type, transport type, status and number of disks contains - * the filter string - */ - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getName() + getVolumeTypeStr() + getTransportTypeStr() + getStatusStr() - + getNumOfDisks(), filterString, caseSensitive); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java deleted file mode 100644 index 44e45df5..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * VolumeOptionInfo.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 javax.xml.bind.annotation.XmlRootElement; - -/** - * Class to hold information about a volume option - */ -@XmlRootElement(name = "volumeOption") -public class VolumeOptionInfo { - private String name; - private String description; - private String defaultValue; - - public VolumeOptionInfo() { - } - - public VolumeOptionInfo(String name, String description, String defaultValue) { - setName(name); - setDescription(description); - setDefaultValue(defaultValue); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/DateUtil.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/DateUtil.java deleted file mode 100644 index 1b284cb8..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/DateUtil.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * 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.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class DateUtil { - public static final String formatDate(Date inputDate) { - DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); - return formatter.format(inputDate); - } - - public static final String formatTime(Date inputDate) { - DateFormat formatter = new SimpleDateFormat("HH:mm:ss z"); - return formatter.format(inputDate); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java deleted file mode 100644 index c650d632..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.io.File; -import java.io.FileInputStream; -import java.io.InputStream; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; - -public class FileUtil { - public String readFileAsString(File file) { - try { - FileInputStream fileInputStream = new FileInputStream(file); - byte[] data = new byte[fileInputStream.available()]; - fileInputStream.read(data); - fileInputStream.close(); - - return new String(data); - } catch (Exception e) { - e.printStackTrace(); - throw new GlusterRuntimeException("Could not read file [" + file + "]", e); - } - } - - public InputStream loadResource(String resourcePath) { - return this.getClass().getClassLoader().getResourceAsStream(resourcePath); - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java deleted file mode 100644 index ad5b4c2b..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java +++ /dev/null @@ -1,218 +0,0 @@ -/** - * GlusterUtil.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.io.File; -import java.util.ArrayList; -import java.util.List; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.GlusterServer.SERVER_STATUS; -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; - -/** - * - */ -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 = "Connected"; - private static final ProcessUtil processUtil = new ProcessUtil(); - - /** - * 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 - */ - private final String extractToken(String line, String token) { - if (line.contains(token)) { - return line.split(token)[1].trim(); - } - return null; - } - - public List<GlusterServer> getGlusterServers() { - String output = getPeerStatus(); - if (output == null) { - return null; - } - - List<GlusterServer> glusterServers = new ArrayList<GlusterServer>(); - 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; - } - - public List<String> getGlusterServerNames() { - String output = getPeerStatus(); - if(output == null) { - return null; - } - - List<String> glusterServerNames = new ArrayList<String>(); - for (String line : output.split(CoreConstants.NEWLINE)) { - String hostName = extractToken(line, HOSTNAME_PFX); - if (hostName != null) { - glusterServerNames.add(hostName); - } - } - return glusterServerNames; - } - - private String getPeerStatus() { - String output; - ProcessResult result = processUtil.executeCommand("gluster", "peer", "status"); - if (!result.isSuccess()) { - output = null; - } - output = result.getOutput(); - return output; - } - - public ProcessResult addServer(String serverName) { - return processUtil.executeCommand("gluster", "peer", "probe", serverName); - } - - - public ProcessResult startVolume(String volumeName) { - return processUtil.executeCommand("gluster", "volume", "start", volumeName); - } - - public ProcessResult stopVolume(String volumeName) { - return processUtil.executeCommand("gluster", "--mode=script", "volume", "stop", volumeName); - } - - public ProcessResult createVolume(Volume volume) { - int count=1; // replica or stripe count - String volumeType = null; - VOLUME_TYPE volType = volume.getVolumeType(); - if(volType == VOLUME_TYPE.DISTRIBUTED_MIRROR) { - volumeType = "replica"; - count = 2; - } else if(volType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { - volumeType = "stripe"; - count = 4; - } - - String transportTypeStr = null; - TRANSPORT_TYPE transportType = volume.getTransportType(); - transportTypeStr = (transportType == TRANSPORT_TYPE.ETHERNET) ? "tcp" : "rdma"; - - List<String> command = new ArrayList<String>(); - command.add("gluster"); - command.add("volume"); - command.add("create"); - command.add(volume.getName()); - if(volumeType != null) { - command.add(volumeType); - command.add("" + count); - } - command.add("transport"); - command.add(transportTypeStr); - for(Disk disk : volume.getDisks()) { - command.add(getBrickNotation(volume, disk)); - } - return processUtil.executeCommand(command); - } - - public ProcessResult setOption(List<String> command) { - return processUtil.executeCommand(command); - } - - public ProcessResult setVolumeAccessControl(Volume volume) { - List<String> command = new ArrayList<String>(); - command.add("gluster"); - command.add("volume"); - command.add("set"); - command.add(volume.getName()); - command.add("auth.allow"); - command.add(volume.getAccessControlList()); - return setOption(command); - } - - /** - * @param disk - * @return - */ - private String getBrickNotation(Volume vol, Disk disk) { - // TODO: Figure out an appropriate directory INSIDE the DISK having given NAME (e.g. sda, sdb, etc) - // String dirName = "/export/" + vol.getName() + "/" + disk.getName(); - - // if /export directory is not exist then create the directory - boolean exists = (new File("/export")).exists(); - - if (!exists) { - processUtil.executeCommand("mkdir", "/export"); - } - String dirName = "/export/" + vol.getName() ; - return disk.getServerName() + ":" + dirName; - } - - public static void main(String args[]) { - List<String> names = new GlusterUtil().getGlusterServerNames(); - System.out.println(names); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5.java deleted file mode 100644 index e0daaf81..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5.java +++ /dev/null @@ -1,504 +0,0 @@ -/* - * MD5 in Java JDK Beta-2 - * written Santeri Paavolainen, Helsinki Finland 1996 - * (c) Santeri Paavolainen, Helsinki Finland 1996 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * See http://www.cs.hut.fi/~santtu/java/ for more information on this - * class. - * - * This is rather straight re-implementation of the reference implementation - * given in RFC1321 by RSA. - * - * Passes MD5 test suite as defined in RFC1321. - * - * - * This Java class has been derivedfrom the RSA Data Security, Inc. MD5 - * Message-Digest Algorithm and its reference implementation. - * - * - * $Log: MD5.java,v $ - * Revision 1.1 2004/07/12 13:35:20 aubryp - * initial commit - * - * Revision 1.3 2002/03/16 01:46:39 broccol - * Moved the MD5 classes into the md5 package to make 1.4 javac happy - * - * Revision 1.2 1999/11/04 21:38:00 broccol - * Got MD5Crypt calculating the same hash as the OpenBSD md5crypt.c routine. - * - * Revision 1.1 1999/08/05 22:07:03 broccol - * Added support for the MD5 classes. - * - * Revision 1.3 1996/04/15 07:28:09 santtu - * Added GPL statements, and RSA derivate statements. - * - * Revision 1.2 1996/03/04 08:05:48 santtu - * Added offsets to Update method - * - * Revision 1.1 1996/01/07 20:51:59 santtu - * Initial revision - * - */ -package com.gluster.storage.management.core.utils; - -/** - * Contains internal state of the MD5 class - * - * @author Santeri Paavolainen <sjpaavol@cc.helsinki.fi> - */ - -class MD5State { - /** - * 128-byte state - */ - int state[]; - - /** - * 64-bit character count (could be true Java long?) - */ - int count[]; - - /** - * 64-byte buffer (512 bits) for storing to-be-hashed characters - */ - byte buffer[]; - - public MD5State() { - buffer = new byte[64]; - count = new int[2]; - state = new int[4]; - - state[0] = 0x67452301; - state[1] = 0xefcdab89; - state[2] = 0x98badcfe; - state[3] = 0x10325476; - - count[0] = count[1] = 0; - } - - /** Create this State as a copy of another state */ - public MD5State(MD5State from) { - this (); - - int i; - - for (i = 0; i < buffer.length; i++) - this .buffer[i] = from.buffer[i]; - - for (i = 0; i < state.length; i++) - this .state[i] = from.state[i]; - - for (i = 0; i < count.length; i++) - this .count[i] = from.count[i]; - } -}; - -/** - * Implementation of RSA's MD5 hash generator - * - * @version $Revision: 1.1 $ - * @author Santeri Paavolainen <sjpaavol@cc.helsinki.fi> - */ - -public class MD5 { - /** - * MD5 state - */ - MD5State state; - - /** - * If Final() has been called, finals is set to the current finals - * state. Any Update() causes this to be set to null. - */ - MD5State finals; - - /** - * Padding for Final() - */ - static byte padding[] = { (byte) 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - /** - * Initialize MD5 internal state (object can be reused just by - * calling Init() after every Final() - */ - public synchronized void Init() { - state = new MD5State(); - finals = null; - } - - /** - * Class constructor - */ - public MD5() { - this .Init(); - } - - /** - * Initialize class, and update hash with ob.toString() - * - * @param ob Object, ob.toString() is used to update hash - * after initialization - */ - public MD5(Object ob) { - this (); - Update(ob.toString()); - } - - public String debugDump() { - return asHex(); - } - - private int rotate_left(int x, int n) { - return (x << n) | (x >>> (32 - n)); - } - - /* I wonder how many loops and hoops you'll have to go through to - get unsigned add for longs in java */ - - private int uadd(int a, int b) { - long aa, bb; - aa = ((long) a) & 0xffffffffL; - bb = ((long) b) & 0xffffffffL; - - aa += bb; - - return (int) (aa & 0xffffffffL); - } - - private int uadd(int a, int b, int c) { - return uadd(uadd(a, b), c); - } - - private int uadd(int a, int b, int c, int d) { - return uadd(uadd(a, b, c), d); - } - - private int FF(int a, int b, int c, int d, int x, int s, int ac) { - a = uadd(a, ((b & c) | (~b & d)), x, ac); - return uadd(rotate_left(a, s), b); - } - - private int GG(int a, int b, int c, int d, int x, int s, int ac) { - a = uadd(a, ((b & d) | (c & ~d)), x, ac); - return uadd(rotate_left(a, s), b); - } - - private int HH(int a, int b, int c, int d, int x, int s, int ac) { - a = uadd(a, (b ^ c ^ d), x, ac); - return uadd(rotate_left(a, s), b); - } - - private int II(int a, int b, int c, int d, int x, int s, int ac) { - a = uadd(a, (c ^ (b | ~d)), x, ac); - return uadd(rotate_left(a, s), b); - } - - private int[] Decode(byte buffer[], int len, int shift) { - int out[]; - int i, j; - - out = new int[16]; - - for (i = j = 0; j < len; i++, j += 4) { - out[i] = ((int) (buffer[j + shift] & 0xff)) - | (((int) (buffer[j + 1 + shift] & 0xff)) << 8) - | (((int) (buffer[j + 2 + shift] & 0xff)) << 16) - | (((int) (buffer[j + 3 + shift] & 0xff)) << 24); - } - - return out; - } - - private void Transform(MD5State state, byte buffer[], int shift) { - int a = state.state[0], b = state.state[1], c = state.state[2], d = state.state[3], x[]; - - x = Decode(buffer, 64, shift); - - /* Round 1 */ - a = FF(a, b, c, d, x[0], 7, 0xd76aa478); /* 1 */ - d = FF(d, a, b, c, x[1], 12, 0xe8c7b756); /* 2 */ - c = FF(c, d, a, b, x[2], 17, 0x242070db); /* 3 */ - b = FF(b, c, d, a, x[3], 22, 0xc1bdceee); /* 4 */ - a = FF(a, b, c, d, x[4], 7, 0xf57c0faf); /* 5 */ - d = FF(d, a, b, c, x[5], 12, 0x4787c62a); /* 6 */ - c = FF(c, d, a, b, x[6], 17, 0xa8304613); /* 7 */ - b = FF(b, c, d, a, x[7], 22, 0xfd469501); /* 8 */ - a = FF(a, b, c, d, x[8], 7, 0x698098d8); /* 9 */ - d = FF(d, a, b, c, x[9], 12, 0x8b44f7af); /* 10 */ - c = FF(c, d, a, b, x[10], 17, 0xffff5bb1); /* 11 */ - b = FF(b, c, d, a, x[11], 22, 0x895cd7be); /* 12 */ - a = FF(a, b, c, d, x[12], 7, 0x6b901122); /* 13 */ - d = FF(d, a, b, c, x[13], 12, 0xfd987193); /* 14 */ - c = FF(c, d, a, b, x[14], 17, 0xa679438e); /* 15 */ - b = FF(b, c, d, a, x[15], 22, 0x49b40821); /* 16 */ - - /* Round 2 */ - a = GG(a, b, c, d, x[1], 5, 0xf61e2562); /* 17 */ - d = GG(d, a, b, c, x[6], 9, 0xc040b340); /* 18 */ - c = GG(c, d, a, b, x[11], 14, 0x265e5a51); /* 19 */ - b = GG(b, c, d, a, x[0], 20, 0xe9b6c7aa); /* 20 */ - a = GG(a, b, c, d, x[5], 5, 0xd62f105d); /* 21 */ - d = GG(d, a, b, c, x[10], 9, 0x2441453); /* 22 */ - c = GG(c, d, a, b, x[15], 14, 0xd8a1e681); /* 23 */ - b = GG(b, c, d, a, x[4], 20, 0xe7d3fbc8); /* 24 */ - a = GG(a, b, c, d, x[9], 5, 0x21e1cde6); /* 25 */ - d = GG(d, a, b, c, x[14], 9, 0xc33707d6); /* 26 */ - c = GG(c, d, a, b, x[3], 14, 0xf4d50d87); /* 27 */ - b = GG(b, c, d, a, x[8], 20, 0x455a14ed); /* 28 */ - a = GG(a, b, c, d, x[13], 5, 0xa9e3e905); /* 29 */ - d = GG(d, a, b, c, x[2], 9, 0xfcefa3f8); /* 30 */ - c = GG(c, d, a, b, x[7], 14, 0x676f02d9); /* 31 */ - b = GG(b, c, d, a, x[12], 20, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - a = HH(a, b, c, d, x[5], 4, 0xfffa3942); /* 33 */ - d = HH(d, a, b, c, x[8], 11, 0x8771f681); /* 34 */ - c = HH(c, d, a, b, x[11], 16, 0x6d9d6122); /* 35 */ - b = HH(b, c, d, a, x[14], 23, 0xfde5380c); /* 36 */ - a = HH(a, b, c, d, x[1], 4, 0xa4beea44); /* 37 */ - d = HH(d, a, b, c, x[4], 11, 0x4bdecfa9); /* 38 */ - c = HH(c, d, a, b, x[7], 16, 0xf6bb4b60); /* 39 */ - b = HH(b, c, d, a, x[10], 23, 0xbebfbc70); /* 40 */ - a = HH(a, b, c, d, x[13], 4, 0x289b7ec6); /* 41 */ - d = HH(d, a, b, c, x[0], 11, 0xeaa127fa); /* 42 */ - c = HH(c, d, a, b, x[3], 16, 0xd4ef3085); /* 43 */ - b = HH(b, c, d, a, x[6], 23, 0x4881d05); /* 44 */ - a = HH(a, b, c, d, x[9], 4, 0xd9d4d039); /* 45 */ - d = HH(d, a, b, c, x[12], 11, 0xe6db99e5); /* 46 */ - c = HH(c, d, a, b, x[15], 16, 0x1fa27cf8); /* 47 */ - b = HH(b, c, d, a, x[2], 23, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - a = II(a, b, c, d, x[0], 6, 0xf4292244); /* 49 */ - d = II(d, a, b, c, x[7], 10, 0x432aff97); /* 50 */ - c = II(c, d, a, b, x[14], 15, 0xab9423a7); /* 51 */ - b = II(b, c, d, a, x[5], 21, 0xfc93a039); /* 52 */ - a = II(a, b, c, d, x[12], 6, 0x655b59c3); /* 53 */ - d = II(d, a, b, c, x[3], 10, 0x8f0ccc92); /* 54 */ - c = II(c, d, a, b, x[10], 15, 0xffeff47d); /* 55 */ - b = II(b, c, d, a, x[1], 21, 0x85845dd1); /* 56 */ - a = II(a, b, c, d, x[8], 6, 0x6fa87e4f); /* 57 */ - d = II(d, a, b, c, x[15], 10, 0xfe2ce6e0); /* 58 */ - c = II(c, d, a, b, x[6], 15, 0xa3014314); /* 59 */ - b = II(b, c, d, a, x[13], 21, 0x4e0811a1); /* 60 */ - a = II(a, b, c, d, x[4], 6, 0xf7537e82); /* 61 */ - d = II(d, a, b, c, x[11], 10, 0xbd3af235); /* 62 */ - c = II(c, d, a, b, x[2], 15, 0x2ad7d2bb); /* 63 */ - b = II(b, c, d, a, x[9], 21, 0xeb86d391); /* 64 */ - - state.state[0] += a; - state.state[1] += b; - state.state[2] += c; - state.state[3] += d; - } - - /** - * Updates hash with the bytebuffer given (using at maximum length bytes from - * that buffer) - * - * @param stat Which state is updated - * @param buffer Array of bytes to be hashed - * @param offset Offset to buffer array - * @param length Use at maximum `length' bytes (absolute - * maximum is buffer.length) - */ - public void Update(MD5State stat, byte buffer[], int offset, - int length) { - int index, partlen, i, start; - - finals = null; - - /* Length can be told to be shorter, but not inter */ - if ((length - offset) > buffer.length) - length = buffer.length - offset; - - /* compute number of bytes mod 64 */ - index = (int) (stat.count[0] >>> 3) & 0x3f; - - if ((stat.count[0] += (length << 3)) < (length << 3)) - stat.count[1]++; - - stat.count[1] += length >>> 29; - - partlen = 64 - index; - - if (length >= partlen) { - for (i = 0; i < partlen; i++) - stat.buffer[i + index] = buffer[i + offset]; - - Transform(stat, stat.buffer, 0); - - for (i = partlen; (i + 63) < length; i += 64) - Transform(stat, buffer, i); - - index = 0; - } else - i = 0; - - /* buffer remaining input */ - if (i < length) { - start = i; - for (; i < length; i++) - stat.buffer[index + i - start] = buffer[i + offset]; - } - } - - /* - * Update()s for other datatypes than byte[] also. Update(byte[], int) - * is only the main driver. - */ - - /** - * Plain update, updates this object - */ - - public void Update(byte buffer[], int offset, int length) { - Update(this .state, buffer, offset, length); - } - - public void Update(byte buffer[], int length) { - Update(this .state, buffer, 0, length); - } - - /** - * Updates hash with given array of bytes - * - * @param buffer Array of bytes to use for updating the hash - */ - public void Update(byte buffer[]) { - Update(buffer, 0, buffer.length); - } - - /** - * Updates hash with a single byte - * - * @param b Single byte to update the hash - */ - public void Update(byte b) { - byte buffer[] = new byte[1]; - buffer[0] = b; - - Update(buffer, 1); - } - - /** - * Update buffer with given string. - * - * @param s String to be update to hash (is used as - * s.getBytes()) - */ - public void Update(String s) { - byte chars[]; - - chars = s.getBytes(); - - Update(chars, chars.length); - } - - private byte[] Encode(int input[], int len) { - int i, j; - byte out[]; - - out = new byte[len]; - - for (i = j = 0; j < len; i++, j += 4) { - out[j] = (byte) (input[i] & 0xff); - out[j + 1] = (byte) ((input[i] >>> 8) & 0xff); - out[j + 2] = (byte) ((input[i] >>> 16) & 0xff); - out[j + 3] = (byte) ((input[i] >>> 24) & 0xff); - } - - return out; - } - - /** - * Returns array of bytes (16 bytes) representing hash as of the - * current state of this object. Note: getting a hash does not - * invalidate the hash object, it only creates a copy of the real - * state which is finalized. - * - * @return Array of 16 bytes, the hash of all updated bytes - */ - public synchronized byte[] Final() { - byte bits[]; - int index, padlen; - MD5State fin; - - if (finals == null) { - fin = new MD5State(state); - - bits = Encode(fin.count, 8); - - index = (int) ((fin.count[0] >>> 3) & 0x3f); - padlen = (index < 56) ? (56 - index) : (120 - index); - - Update(fin, padding, 0, padlen); - /**/ - Update(fin, bits, 0, 8); - - /* Update() sets finalds to null */ - finals = fin; - } - - return Encode(finals.state, 16); - } - - /** - * Turns array of bytes into string representing each byte as - * unsigned hex number. - * - * @param hash Array of bytes to convert to hex-string - * @return Generated hex string - */ - public static String asHex(byte hash[]) { - StringBuffer buf = new StringBuffer(hash.length * 2); - int i; - - for (i = 0; i < hash.length; i++) { - if (((int) hash[i] & 0xff) < 0x10) - buf.append("0"); - - buf.append(Long.toString((int) hash[i] & 0xff, 16)); - } - - return buf.toString(); - } - - /** - * Returns 32-character hex representation of this objects hash - * - * @return String of this object's hash - */ - public String asHex() { - return asHex(this .Final()); - } - - /** - * One-stop md5 string encrypting. - */ - - public static String md5crypt(String input) { - MD5 md5 = new MD5(); - md5.Init(); - md5.Update(input); - return md5.asHex(); - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5Crypt.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5Crypt.java deleted file mode 100644 index 25c757a2..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5Crypt.java +++ /dev/null @@ -1,339 +0,0 @@ -/*------------------------------------------------------------------------------ - class - MD5Crypt - ------------------------------------------------------------------------------*/ - -package com.gluster.storage.management.core.utils; - - -/** - * <p>This class defines a method, - * {@link MD5Crypt#crypt(java.lang.String, java.lang.String) crypt()}, which - * takes a password and a salt string and generates an OpenBSD/FreeBSD/Linux-compatible - * md5-encoded password entry.</p> - * - * <p>Created: 3 November 1999</p> - * <p>Release: $Name: $</p> - * <p>Version: $Revision: 1.1 $</p> - * <p>Last Mod Date: $Date: 2004/07/12 13:35:20 $</p> - * <p>Java Code By: Jonathan Abbey, jonabbey@arlut.utexas.edu</p> - * <p>Original C Version:<pre> - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * </pre></p> - * - * @author Jonathan Abbey <jonabbey at arlut.utexas.edu> - */ -public final class MD5Crypt { - - /** - * - * Command line test rig. - * - */ - - static public void main(String argv[]) { - if ((argv.length < 1) || (argv.length > 3)) { - System.err - .println("Usage: MD5Crypt [-apache] password salt"); - System.exit(1); - } - - if (argv.length == 3) { - System.err.println(MD5Crypt.apacheCrypt(argv[1], argv[2])); - } else if (argv.length == 2) { - System.err.println(MD5Crypt.crypt(argv[0], argv[1])); - } else { - System.err.println(MD5Crypt.crypt(argv[0])); - } - - System.exit(0); - } - - static private final String SALTCHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - - static private final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - - static private final String to64(long v, int size) { - StringBuffer result = new StringBuffer(); - - while (--size >= 0) { - result.append(itoa64.charAt((int) (v & 0x3f))); - v >>>= 6; - } - - return result.toString(); - } - - static private final void clearbits(byte bits[]) { - for (int i = 0; i < bits.length; i++) { - bits[i] = 0; - } - } - - /** - * convert an encoded unsigned byte value into a int - * with the unsigned value. - */ - - static private final int bytes2u(byte inp) { - return (int) inp & 0xff; - } - - /** - * <p>This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible - * md5-encoded password hash from a plaintext password and a - * salt.</p> - * - * <p>The resulting string will be in the form '$1$<salt>$<hashed mess></p> - * - * @param password Plaintext password - * - * @return An OpenBSD/FreeBSD/Linux-compatible md5-hashed password field. - */ - - static public final String crypt(String password) { - StringBuffer salt = new StringBuffer(); - java.util.Random randgen = new java.util.Random(); - - /* -- */ - - while (salt.length() < 8) { - int index = (int) (randgen.nextFloat() * SALTCHARS.length()); - salt.append(SALTCHARS.substring(index, index + 1)); - } - - return MD5Crypt.crypt(password, salt.toString()); - } - - /** - * <p>This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible - * md5-encoded password hash from a plaintext password and a - * salt.</p> - * - * <p>The resulting string will be in the form '$1$<salt>$<hashed mess></p> - * - * @param password Plaintext password - * @param salt A short string to use to randomize md5. May start with $1$, which - * will be ignored. It is explicitly permitted to pass a pre-existing - * MD5Crypt'ed password entry as the salt. crypt() will strip the salt - * chars out properly. - * - * @return An OpenBSD/FreeBSD/Linux-compatible md5-hashed password field. - */ - - static public final String crypt(String password, String salt) { - return MD5Crypt.crypt(password, salt, "$1$"); - } - - /** - * <p>This method generates an Apache MD5 compatible - * md5-encoded password hash from a plaintext password and a - * salt.</p> - * - * <p>The resulting string will be in the form '$apr1$<salt>$<hashed mess></p> - * - * @param password Plaintext password - * - * @return An Apache-compatible md5-hashed password string. - */ - - static public final String apacheCrypt(String password) { - StringBuffer salt = new StringBuffer(); - java.util.Random randgen = new java.util.Random(); - - /* -- */ - - while (salt.length() < 8) { - int index = (int) (randgen.nextFloat() * SALTCHARS.length()); - salt.append(SALTCHARS.substring(index, index + 1)); - } - - return MD5Crypt.apacheCrypt(password, salt.toString()); - } - - /** - * <p>This method actually generates an Apache MD5 compatible - * md5-encoded password hash from a plaintext password and a - * salt.</p> - * - * <p>The resulting string will be in the form '$apr1$<salt>$<hashed mess></p> - * - * @param password Plaintext password - * @param salt A short string to use to randomize md5. May start with $apr1$, which - * will be ignored. It is explicitly permitted to pass a pre-existing - * MD5Crypt'ed password entry as the salt. crypt() will strip the salt - * chars out properly. - * - * @return An Apache-compatible md5-hashed password string. - */ - - static public final String apacheCrypt(String password, String salt) { - return MD5Crypt.crypt(password, salt, "$apr1$"); - } - - /** - * <p>This method actually generates md5-encoded password hash from - * a plaintext password, a salt, and a magic string.</p> - * - * <p>There are two magic strings that make sense to use here.. '$1$' is the - * magic string used by the FreeBSD/Linux/OpenBSD MD5Crypt algorithm, and - * '$apr1$' is the magic string used by the Apache MD5Crypt algorithm.</p> - * - * <p>The resulting string will be in the form '<magic><salt>$<hashed mess></p> - * - * @param password Plaintext password @param salt A short string to - * use to randomize md5. May start with the magic string, which - * will be ignored. It is explicitly permitted to pass a - * pre-existing MD5Crypt'ed password entry as the salt. crypt() - * will strip the salt chars out properly. - * - * @return An md5-hashed password string. - */ - - static public final String crypt(String password, String salt, - String magic) { - /* This string is magic for this algorithm. Having it this way, - * we can get get better later on */ - - byte finalState[]; - MD5 ctx, ctx1; - long l; - - /* -- */ - - /* Refine the Salt first */ - - /* If it starts with the magic string, then skip that */ - - if (salt.startsWith(magic)) { - salt = salt.substring(magic.length()); - } - - /* It stops at the first '$', max 8 chars */ - - if (salt.indexOf('$') != -1) { - salt = salt.substring(0, salt.indexOf('$')); - } - - if (salt.length() > 8) { - salt = salt.substring(0, 8); - } - - ctx = new MD5(); - - ctx.Update(password); // The password first, since that is what is most unknown - ctx.Update(magic); // Then our magic string - ctx.Update(salt); // Then the raw salt - - /* Then just as many characters of the MD5(pw,salt,pw) */ - - ctx1 = new MD5(); - ctx1.Update(password); - ctx1.Update(salt); - ctx1.Update(password); - finalState = ctx1.Final(); - - for (int pl = password.length(); pl > 0; pl -= 16) { - ctx.Update(finalState, pl > 16 ? 16 : pl); - } - - /* the original code claimed that finalState was being cleared - to keep dangerous bits out of memory, but doing this is also - required in order to get the right output. */ - - clearbits(finalState); - - /* Then something really weird... */ - - for (int i = password.length(); i != 0; i >>>= 1) { - if ((i & 1) != 0) { - ctx.Update(finalState, 1); - } else { - ctx.Update(password.getBytes(), 1); - } - } - - finalState = ctx.Final(); - - /* - * and now, just to make sure things don't run too fast - * On a 60 Mhz Pentium this takes 34 msec, so you would - * need 30 seconds to build a 1000 entry dictionary... - * - * (The above timings from the C version) - */ - - for (int i = 0; i < 1000; i++) { - ctx1 = new MD5(); - - if ((i & 1) != 0) { - ctx1.Update(password); - } else { - ctx1.Update(finalState, 16); - } - - if ((i % 3) != 0) { - ctx1.Update(salt); - } - - if ((i % 7) != 0) { - ctx1.Update(password); - } - - if ((i & 1) != 0) { - ctx1.Update(finalState, 16); - } else { - ctx1.Update(password); - } - - finalState = ctx1.Final(); - } - - /* Now make the output string */ - - StringBuffer result = new StringBuffer(); - - result.append(magic); - result.append(salt); - result.append("$"); - - l = (bytes2u(finalState[0]) << 16) - | (bytes2u(finalState[6]) << 8) - | bytes2u(finalState[12]); - result.append(to64(l, 4)); - - l = (bytes2u(finalState[1]) << 16) - | (bytes2u(finalState[7]) << 8) - | bytes2u(finalState[13]); - result.append(to64(l, 4)); - - l = (bytes2u(finalState[2]) << 16) - | (bytes2u(finalState[8]) << 8) - | bytes2u(finalState[14]); - result.append(to64(l, 4)); - - l = (bytes2u(finalState[3]) << 16) - | (bytes2u(finalState[9]) << 8) - | bytes2u(finalState[15]); - result.append(to64(l, 4)); - - l = (bytes2u(finalState[4]) << 16) - | (bytes2u(finalState[10]) << 8) - | bytes2u(finalState[5]); - result.append(to64(l, 4)); - - l = bytes2u(finalState[11]); - result.append(to64(l, 2)); - - /* Don't leave anything around in vm they could use. */ - clearbits(finalState); - - return result.toString(); - } -} - diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/NumberUtil.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/NumberUtil.java deleted file mode 100644 index 9b1cd5e2..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/NumberUtil.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * 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.text.NumberFormat; - -public class NumberUtil { - public static final String formatNumber(double num) { - NumberFormat formatter = NumberFormat.getNumberInstance(); - formatter.setMinimumFractionDigits(2); - formatter.setMaximumFractionDigits(2); - return formatter.format(num); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java deleted file mode 100644 index 6c8b857d..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * 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 javax.xml.bind.annotation.XmlRootElement; - -/** - * Represents the result of a command execution in a separate process. Consists of the "exit status" of the process and - * output from the process. The output includes stdout as well as stderr streams - */ -@XmlRootElement -public class ProcessResult { - - public static final int SUCCESS = 0; - private int exitValue; - private String output; - - // Required for JAXB de-serialization - public ProcessResult() { - - } - - public ProcessResult(int exitValue, String output) { - this.exitValue = exitValue; - this.output = output; - } - - public int getExitValue() { - return exitValue; - } - - public void setExitValue(int exitValue) { - this.exitValue = exitValue; - } - - public String getOutput() { - return output; - } - - public void setOutput(String output) { - this.output = output; - } - - public boolean isSuccess() { - return exitValue == SUCCESS; - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessUtil.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessUtil.java deleted file mode 100644 index 507c6d95..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessUtil.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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 static com.gluster.storage.management.core.constants.CoreConstants.NEWLINE; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; - -/** - * Utility class for creating processes (foreground/background) with given - * command and checking the output/exit status - */ -public class ProcessUtil { - - private static final ProcessUtil instance = new ProcessUtil(); - - public ProcessResult executeCommand(List<String> command) { - return executeCommand(true, command); - } - - /** - * Executes given command in a separate process in FOREGROUND - * @param command - * @return {@link ProcessResult} object - */ - public ProcessResult executeCommand(String... command) { - ArrayList<String> commandList = new ArrayList<String>(); - for (String part : command) { - commandList.add(part); - } - return executeCommand(commandList); - } - - /** - * Executes given command in foreground/background - * @param runInForeground Boolean flag indicating whether the command should - * be executed in foreground - * @param command - * @return {@link ProcessResult} object - */ - public ProcessResult executeCommand(boolean runInForeground, List<String> command) { - StringBuilder output = new StringBuilder(); - try { - Process process = new ProcessBuilder(command).redirectErrorStream(true).start(); - - if (runInForeground) { - process.waitFor(); // Wait for process to finish - - InputStream is = process.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - String line; - - while ((line = br.readLine()) != null) { - output.append(line); - output.append(NEWLINE); - } - } else { - output.append("Command ["); - output.append(command); - output.append("] triggerred in background."); - } - - return new ProcessResult(process.exitValue(), output.toString()); - } catch (Throwable e) { - throw new GlusterRuntimeException("Exception while executing command [" + command + "]", e); - } - } - - public static void main(String args[]) { - ProcessResult result = new ProcessUtil().executeCommand("ls", "-lrt", "/"); - System.out.println(result.getExitValue()); - System.out.println(result.getOutput()); - } -} diff --git a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java b/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java deleted file mode 100644 index 1c4e6893..00000000 --- a/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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; - -public class StringUtil { - public static boolean filterString(String sourceString, - String filterString, boolean caseSensitive) { - return caseSensitive ? sourceString.contains(filterString) - : sourceString.toLowerCase().contains( - filterString.toLowerCase()); - } -} |
