Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping 2472f2ab0 -> 36649e99d


improving the meta data client


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/36649e99
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/36649e99
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/36649e99

Branch: refs/heads/4.0.0-grouping
Commit: 36649e99d88caa81e00d12b5f4a81e924b8fe738
Parents: 2472f2a
Author: Isuru Haththotuwa <[email protected]>
Authored: Fri Sep 19 19:14:35 2014 +0530
Committer: Isuru Haththotuwa <[email protected]>
Committed: Fri Sep 19 19:14:35 2014 +0530

----------------------------------------------------------------------
 .../client/MetaDataServiceClientManager.java    | 94 --------------------
 .../client/config/MetaDataClientConfig.java     | 58 ++++++++++++
 .../client/data/extractor/DataExtractor.java    |  2 +-
 .../data/extractor/DefaultDataExtractor.java    | 40 ---------
 .../client/sample/DefaultDataExtractor.java     | 41 +++++++++
 .../sample/MetaDataServiceClientManager.java    | 81 +++++++++++++++++
 6 files changed, 181 insertions(+), 135 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/36649e99/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java
 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java
deleted file mode 100644
index 527dfab..0000000
--- 
a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.metadata.client;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadata.client.data.extractor.DataExtractor;
-import org.apache.stratos.metadata.client.data.extractor.DefaultDataExtractor;
-import org.apache.stratos.metadata.client.exception.DataExtractorException;
-import 
org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption;
-import org.apache.stratos.metadata.client.pojo.DataContext;
-
-import java.util.Collection;
-
-public class MetaDataServiceClientManager {
-
-    private static final Log log = 
LogFactory.getLog(MetaDataServiceClientManager.class);
-
-    private MetaDataServiceClient metaDataServiceClient;
-
-    private DataExtractor dataExtractor;
-
-    private String baseUrl;
-
-    private String customDataExtractorClassName;
-
-
-    public MetaDataServiceClientManager () {
-
-        readConfigurations();
-        init();
-    }
-
-    private void readConfigurations () {
-        //TODO: read configurations
-    }
-
-    private void init () {
-
-        metaDataServiceClient = new DefaultMetaDataServiceClient(baseUrl);
-        metaDataServiceClient.initialize();
-        //TODO:  load the relevant customized class
-        // currently only the default DataExtractor is used
-        dataExtractor = new DefaultDataExtractor();
-        dataExtractor.initialize();
-    }
-
-    public void addExtractedData () {
-
-        Collection<DataContext> dataContexts = null;
-
-        try {
-            dataContexts = dataExtractor.getData();
-
-        } catch (DataExtractorException e) {
-            log.error("Unable to get extracted data", e);
-        }
-
-        for (DataContext dataContext : dataContexts) {
-            if (dataContext.getPropertyValues() != null) {
-                for (String propertyValue : dataContext.getPropertyValues()) {
-                    try {
-                        
metaDataServiceClient.addProperty(dataContext.getAppId(), 
dataContext.getClusterId(),
-                                dataContext.getPropertyKey(), propertyValue);
-
-                    } catch (MetaDataServiceClientExeption e) {
-                        log.error("Unable to add extracted data meta data 
service", e);
-                    }
-                }
-            }
-        }
-    }
-
-    public MetaDataServiceClient getMetaDataServiceClient() {
-        return metaDataServiceClient;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/36649e99/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java
 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java
new file mode 100644
index 0000000..a44010c
--- /dev/null
+++ 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.metadata.client.config;
+
+public class MetaDataClientConfig {
+
+    private String metaDataServiceBaseUrl;
+
+    private String customExtractorClassName;
+
+    private static volatile MetaDataClientConfig metaDataClientConfig;
+
+    private MetaDataClientConfig () {
+        readConfig();
+    }
+
+    private void readConfig () {
+        // TODO: read all configurations; metaDataServiceBaseUrl, 
customExtractorClassName
+    }
+
+    public static MetaDataClientConfig getInstance () {
+
+        if (metaDataClientConfig == null) {
+            synchronized (MetaDataClientConfig.class) {
+                if (metaDataClientConfig == null) {
+                    metaDataClientConfig = new MetaDataClientConfig();
+                }
+            }
+        }
+
+        return metaDataClientConfig;
+    }
+
+    public String getMetaDataServiceBaseUrl() {
+        return metaDataServiceBaseUrl;
+    }
+
+    public String getCustomExtractorClassName() {
+        return customExtractorClassName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/36649e99/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java
 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java
index a79237c..af88b22 100644
--- 
a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java
+++ 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java
@@ -28,7 +28,7 @@ public interface DataExtractor {
 
     public void initialize ();
 
-    public Collection<DataContext> getData () throws DataExtractorException;
+    public Collection<DataContext> getData (Object object) throws 
DataExtractorException;
 
     public void terminate () throws DataExtractorException;
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/36649e99/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java
 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java
deleted file mode 100644
index b84c9c7..0000000
--- 
a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.metadata.client.data.extractor;
-
-import org.apache.stratos.metadata.client.exception.DataExtractorException;
-import org.apache.stratos.metadata.client.pojo.DataContext;
-
-import java.util.Collection;
-
-public class DefaultDataExtractor implements DataExtractor {
-
-    public void initialize() {
-        //To change body of implemented methods use File | Settings | File 
Templates.
-    }
-
-    public Collection<DataContext> getData() throws DataExtractorException {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    public void terminate() throws DataExtractorException {
-        //To change body of implemented methods use File | Settings | File 
Templates.
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/36649e99/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java
 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java
new file mode 100644
index 0000000..030ad8f
--- /dev/null
+++ 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.metadata.client.sample;
+
+import org.apache.stratos.metadata.client.data.extractor.DataExtractor;
+import org.apache.stratos.metadata.client.exception.DataExtractorException;
+import org.apache.stratos.metadata.client.pojo.DataContext;
+
+import java.util.Collection;
+
+public class DefaultDataExtractor implements DataExtractor {
+
+    public void initialize() {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+
+    public Collection<DataContext> getData(Object object) throws 
DataExtractorException {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public void terminate() throws DataExtractorException {
+        //To change body of implemented methods use File | Settings | File 
Templates.
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/36649e99/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java
 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java
new file mode 100644
index 0000000..36cecd2
--- /dev/null
+++ 
b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.metadata.client.sample;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.metadata.client.DefaultMetaDataServiceClient;
+import org.apache.stratos.metadata.client.MetaDataServiceClient;
+import org.apache.stratos.metadata.client.config.MetaDataClientConfig;
+import org.apache.stratos.metadata.client.data.extractor.DataExtractor;
+
+public class MetaDataServiceClientManager {
+
+    private static final Log log = 
LogFactory.getLog(MetaDataServiceClientManager.class);
+
+    private MetaDataServiceClient metaDataServiceClient;
+
+    private DataExtractor dataExtractor;
+
+    private MetaDataClientConfig metaDataClientConfig;
+
+
+    public MetaDataServiceClientManager () {
+        initialize();
+    }
+
+    private void initialize() {
+
+        metaDataClientConfig = MetaDataClientConfig.getInstance();
+        metaDataServiceClient = new 
DefaultMetaDataServiceClient(metaDataClientConfig.getMetaDataServiceBaseUrl());
+        metaDataServiceClient.initialize();
+        //TODO:  load the relevant customized class using 
customDataExtractorClassName
+        // currently only the default DataExtractor is used
+        dataExtractor = new DefaultDataExtractor();
+        dataExtractor.initialize();
+    }
+
+//    public void addExtractedData () {
+//
+//        Collection<DataContext> dataContexts = null;
+//
+//        try {
+//            dataContexts = dataExtractor.getData();
+//
+//        } catch (DataExtractorException e) {
+//            log.error("Unable to get extracted data", e);
+//        }
+//
+//        for (DataContext dataContext : dataContexts) {
+//            if (dataContext.getPropertyValues() != null) {
+//                for (String propertyValue : dataContext.getPropertyValues()) 
{
+//                    try {
+//                        
metaDataServiceClient.addProperty(dataContext.getAppId(), 
dataContext.getClusterId(),
+//                                dataContext.getPropertyKey(), propertyValue);
+//
+//                    } catch (MetaDataServiceClientExeption e) {
+//                        log.error("Unable to add extracted data meta data 
service", e);
+//                    }
+//                }
+//            }
+//        }
+//    }
+
+}

Reply via email to