You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by he...@apache.org on 2012/02/24 17:42:59 UTC
svn commit: r1293334 -
/incubator/airavata/trunk/modules/registry-migrator/src/main/java/org/apache/airavata/migrator/registry/XRegistryMigrate.java
Author: heshan
Date: Fri Feb 24 16:42:59 2012
New Revision: 1293334
URL: http://svn.apache.org/viewvc?rev=1293334&view=rev
Log:
AIRAVATA-309 Fixing the save order.
Modified:
incubator/airavata/trunk/modules/registry-migrator/src/main/java/org/apache/airavata/migrator/registry/XRegistryMigrate.java
Modified: incubator/airavata/trunk/modules/registry-migrator/src/main/java/org/apache/airavata/migrator/registry/XRegistryMigrate.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry-migrator/src/main/java/org/apache/airavata/migrator/registry/XRegistryMigrate.java?rev=1293334&r1=1293333&r2=1293334&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry-migrator/src/main/java/org/apache/airavata/migrator/registry/XRegistryMigrate.java (original)
+++ incubator/airavata/trunk/modules/registry-migrator/src/main/java/org/apache/airavata/migrator/registry/XRegistryMigrate.java Fri Feb 24 16:42:59 2012
@@ -26,12 +26,12 @@ public class XRegistryMigrate {
// private static String propertyfile = "xregistry.properties";
// private static String propertyfile = "xregistry-dropbox.properties";
private static String propertyfile = "xregistry-local.properties";
+ private static AiravataJCRRegistry jcrRegistry = null;
public static void main(String[] args) throws XRegistryClientException {
/* Create database */
Map<String,String> config = new HashMap<String,String>();
config.put("org.apache.jackrabbit.repository.home","target");
- AiravataJCRRegistry jcrRegistry = null;
try {
jcrRegistry = new AiravataJCRRegistry(null,
"org.apache.jackrabbit.core.RepositoryFactoryImpl", "admin",
@@ -40,12 +40,13 @@ public class XRegistryMigrate {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
- HostDescription host = null;
- ApplicationDeploymentDescription app = null;
- ServiceDescription service = null;
-
XRegistryClient client = XRegistryClientUtil.CreateGSISecureRegistryInstance(propertyfile);
+ saveAllHostDescriptions(client);
+ saveAllServiceDescriptions(client);
+ }
+ private static HostDescription saveAllHostDescriptions(XRegistryClient client) throws XRegistryClientException {
+ HostDescription host = null;
HostDescData[] hostDescs = client.findHosts("");
Map<QName, HostDescData> val = new HashMap<QName, HostDescData>();
for (HostDescData hostDesc : hostDescs) {
@@ -63,37 +64,31 @@ public class XRegistryMigrate {
host = MigrationUtil.createHostDescription(hostBean);
}
- }
-
- FindAppDescResponseDocument.FindAppDescResponse.AppData[] appDatas = client.findAppDesc("");
- Map<QName, FindAppDescResponseDocument.FindAppDescResponse.AppData> val2 =
- new HashMap<QName, FindAppDescResponseDocument.FindAppDescResponse.AppData>();
- for (FindAppDescResponseDocument.FindAppDescResponse.AppData appDesc : appDatas) {
- val2.put(appDesc.getName(), appDesc);
- String appDescStr = client.getAppDesc(appDesc.getName().toString(),appDesc.getHostName());
- System.out.println(appDescStr);
- ApplicationBean appBean = null;
try {
- appBean = org.ogce.schemas.gfac.beans.utils.ApplicationUtils.simpleApplicationBeanRequest(appDescStr);
- } catch (XmlException e) {
+ jcrRegistry.saveHostDescription(host);
+ } catch (RegistryException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
- if(appBean != null){
- app = MigrationUtil.createAppDeploymentDescription(appBean);
- }
}
+ return host;
+ }
-
+ private static ServiceDescription saveAllServiceDescriptions(XRegistryClient client) throws XRegistryClientException {
+ ServiceDescription service = null;
ServiceDescData[] serviceDescDatas = client.findServiceDesc("");
Map<QName, ServiceDescData> val3 = new HashMap<QName, ServiceDescData>();
+
for (ServiceDescData serviceDesc : serviceDescDatas) {
val3.put(serviceDesc.getName(), serviceDesc);
String serviceDescStr = client.getServiceDesc(serviceDesc.getName());
System.out.println(serviceDescStr);
ServiceBean serviceBean = null;
+ String applicationName = null;
+
try {
serviceBean = org.ogce.schemas.gfac.beans.utils.ServiceUtils.serviceBeanRequest(serviceDescStr);
+ applicationName = serviceBean.getApplicationName();
} catch (XmlException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (IOException e) {
@@ -103,27 +98,74 @@ public class XRegistryMigrate {
if(serviceBean != null) {
service = MigrationUtil.createServiceDescription(serviceBean);
}
- }
- /* Save to registry */
- try {
- if (service != null) {
+ try {
jcrRegistry.saveServiceDescription(service);
+ ApplicationBean appBean = saveApplicationDescriptionWithName(client, applicationName, service);
+ jcrRegistry.deployServiceOnHost(service.getType().getName(), appBean.getHostName());
+ } catch (RegistryException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
+ }
+ return service;
+ }
- if(host != null) {
- jcrRegistry.saveHostDescription(host);
+ private static ApplicationBean saveApplicationDescriptionWithName(XRegistryClient client, String applicationName, ServiceDescription service) throws XRegistryClientException {
+ ApplicationDeploymentDescription app = null;
+ FindAppDescResponseDocument.FindAppDescResponse.AppData[] appDatas = client.findAppDesc(applicationName);
+ Map<QName, FindAppDescResponseDocument.FindAppDescResponse.AppData> val2 =
+ new HashMap<QName, FindAppDescResponseDocument.FindAppDescResponse.AppData>();
+ ApplicationBean appBean = null;
+ for (FindAppDescResponseDocument.FindAppDescResponse.AppData appDesc : appDatas) {
+ val2.put(appDesc.getName(), appDesc);
+ String appDescStr = client.getAppDesc(appDesc.getName().toString(),appDesc.getHostName());
+ System.out.println(appDescStr);
+ try {
+ appBean = org.ogce.schemas.gfac.beans.utils.ApplicationUtils.simpleApplicationBeanRequest(appDescStr);
- if (service != null) {
- jcrRegistry.saveDeploymentDescription(service.getType().getName(), host
- .getType().getHostName(), app);
- jcrRegistry.deployServiceOnHost(service.getType().getName(), host.getType().getHostName());
+ } catch (XmlException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ if(appBean != null){
+ app = MigrationUtil.createAppDeploymentDescription(appBean);
+ try {
+ jcrRegistry.saveDeploymentDescription(service.getType().getName(), appBean.getHostName(), app);
+// jcrRegistry.saveDeploymentDescription(service.getType().getName(), host.getType().getHostName(), app);
+ } catch (RegistryException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
- } catch (RegistryException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+
+
}
+ return appBean;
+ }
+
+ private static void saveAllApplicationDescriptions(XRegistryClient client, ServiceDescription service) throws XRegistryClientException {
+ ApplicationDeploymentDescription app = null;
+ FindAppDescResponseDocument.FindAppDescResponse.AppData[] appDatas = client.findAppDesc("");
+ Map<QName, FindAppDescResponseDocument.FindAppDescResponse.AppData> val2 =
+ new HashMap<QName, FindAppDescResponseDocument.FindAppDescResponse.AppData>();
+ for (FindAppDescResponseDocument.FindAppDescResponse.AppData appDesc : appDatas) {
+ val2.put(appDesc.getName(), appDesc);
+ String appDescStr = client.getAppDesc(appDesc.getName().toString(),appDesc.getHostName());
+ System.out.println(appDescStr);
+ ApplicationBean appBean = null;
+ try {
+ appBean = org.ogce.schemas.gfac.beans.utils.ApplicationUtils.simpleApplicationBeanRequest(appDescStr);
+ } catch (XmlException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ if(appBean != null){
+ app = MigrationUtil.createAppDeploymentDescription(appBean);
+ }
+
+ //jcrRegistry.saveDeploymentDescription(service.getType().getName(), host.getType().getHostName(), app);
+
+ }
}
}