Update of /cvsroot/unicore/unicore6/uas/src/main/java/de/fzj/unicore/uas/util In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv23119/src/main/java/de/fzj/unicore/uas/util Modified Files: AddressingUtil.java CreateSMSOnStartup.java CreateTSSOnStartup.java RegistryUtil.java DefaultOnStartup.java Log Message: update: - add multicast registry discovery - cleanup registry code - refactor filetransfer setup code - fix dir bug in SMS Index: CreateTSSOnStartup.java =================================================================== RCS file: /cvsroot/unicore/unicore6/uas/src/main/java/de/fzj/unicore/uas/util/CreateTSSOnStartup.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CreateTSSOnStartup.java 8 Sep 2006 12:33:48 -0000 1.2 --- CreateTSSOnStartup.java 31 Oct 2006 14:26:10 -0000 1.3 *************** *** 43,46 **** --- 43,47 ---- import de.fzj.unicore.uas.UAS; + import de.fzj.unicore.uas.impl.registry.RegistryHandler; import de.fzj.unicore.wsrflite.Home; import de.fzj.unicore.wsrflite.Kernel; *************** *** 64,68 **** public CreateTSSOnStartup(){ ! registryEpr=UAS.getRegistryEpr(); logger.info("Using registry at "+registryEpr.getAddress().getStringValue()); } --- 65,69 ---- public CreateTSSOnStartup(){ ! registryEpr=RegistryHandler.getRegistryEpr(); logger.info("Using registry at "+registryEpr.getAddress().getStringValue()); } *************** *** 72,75 **** --- 73,83 ---- Home tssHome=Kernel.getKernel().getServiceHome(UAS.TSS); if(tssHome!=null){ + //check if instance already exists + try{ + if(tssHome.getWSRFServiceInstance(INSTANCE_ID)!=null)return; + }catch(Exception e){ + //ok, does not exist + } + Map<String,Object>map=new HashMap<String,Object>(); map.put(WSResourceImpl.INIT_UNIQUE_ID,INSTANCE_ID); *************** *** 87,91 **** AddressingUtil.addUGSRefparamToEpr(epr1,INSTANCE_ID); //store ! try{RegistryUtil.addRegistryEntry(epr1); logger.info("Added TSS instance reference to registry."); }catch(Exception e){ --- 95,99 ---- AddressingUtil.addUGSRefparamToEpr(epr1,INSTANCE_ID); //store ! try{RegistryHandler.getRegistryClient().addRegistryEntry(epr1); logger.info("Added TSS instance reference to registry."); }catch(Exception e){ Index: DefaultOnStartup.java =================================================================== RCS file: /cvsroot/unicore/unicore6/uas/src/main/java/de/fzj/unicore/uas/util/DefaultOnStartup.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DefaultOnStartup.java 26 Oct 2006 13:29:15 -0000 1.4 --- DefaultOnStartup.java 31 Oct 2006 14:26:10 -0000 1.5 *************** *** 45,53 **** import de.fzj.unicore.uas.UAS; import de.fzj.unicore.uas.impl.tss.TargetSystemFactoryHomeImpl; import de.fzj.unicore.uas.xnjs.XNJSFacade; import de.fzj.unicore.wsrflite.Home; import de.fzj.unicore.wsrflite.Kernel; - import de.fzj.unicore.wsrflite.exceptions.ResourceUnknownFault; import de.fzj.unicore.wsrflite.impl.WSResourceImpl; import de.fzj.unicore.wsrflite.utils.Utilities; --- 45,53 ---- import de.fzj.unicore.uas.UAS; + import de.fzj.unicore.uas.impl.registry.RegistryHandler; import de.fzj.unicore.uas.impl.tss.TargetSystemFactoryHomeImpl; import de.fzj.unicore.uas.xnjs.XNJSFacade; import de.fzj.unicore.wsrflite.Home; import de.fzj.unicore.wsrflite.Kernel; import de.fzj.unicore.wsrflite.impl.WSResourceImpl; import de.fzj.unicore.wsrflite.utils.Utilities; *************** *** 64,72 **** public DefaultOnStartup(){ - registryEpr=UAS.getRegistryEpr(); - logger.info("Using registry at "+registryEpr.getAddress().getStringValue()); } public void run(){ try{ logger.info("Initialising backend"); --- 64,71 ---- public DefaultOnStartup(){ } public void run(){ + String defaultTsfName=TargetSystemFactoryHomeImpl.DEFAULT_TSF; try{ logger.info("Initialising backend"); *************** *** 76,99 **** logger.severe("Error initialising backend"); } ! String defaultTsfName=TargetSystemFactoryHomeImpl.DEFAULT_TSF; ! try { ! Home regHome=Kernel.getKernel().getServiceHome(UAS.REG); ! if(regHome!=null){ ! //check if default registry already exists ! try{ ! if(regHome.getWSRFServiceInstance("default_registry")!=null) return; ! }catch(ResourceUnknownFault e){ ! //OK we will build a new one ! } ! // //deploy default registry ! Map<String,Object>map=new HashMap<String,Object>(); ! map.put(WSResourceImpl.INIT_UNIQUE_ID,"default_registry"); ! //set lifetime to three months ! Calendar c1=new GregorianCalendar(); ! c1.add(Calendar.MONTH,3); ! map.put(WSResourceImpl.INIT_INITIAL_TERMINATION_TIME,c1); ! regHome.createWSRFServiceInstance(map); ! logger.info("Added 'default_registry' resource to service "+UAS.REG); ! } //Unicore/GS compatibility code: add a "default" target system factory --- 75,82 ---- logger.severe("Error initialising backend"); } ! ! try ! { ! RegistryHandler.initRegistry(); //Unicore/GS compatibility code: add a "default" target system factory *************** *** 115,119 **** AddressingUtil.addUGSRefparamToEpr(epr1,defaultTsfName); //store ! try{RegistryUtil.addRegistryEntry(epr1); logger.info("Added target system factory reference"); }catch(Exception e){ --- 98,102 ---- AddressingUtil.addUGSRefparamToEpr(epr1,defaultTsfName); //store ! try{RegistryHandler.getRegistryClient().addRegistryEntry(epr1); logger.info("Added target system factory reference"); }catch(Exception e){ Index: RegistryUtil.java =================================================================== RCS file: /cvsroot/unicore/unicore6/uas/src/main/java/de/fzj/unicore/uas/util/RegistryUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RegistryUtil.java 21 Aug 2006 14:23:20 -0000 1.1 --- RegistryUtil.java 31 Oct 2006 14:26:10 -0000 1.2 *************** *** 1,75 **** - /********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - package de.fzj.unicore.uas.util; - - import org.oasisOpen.docs.wsrf.sg2.AddDocument; - import org.oasisOpen.docs.wsrf.sg2.AddResponseDocument; - import org.oasisOpen.docs.wsrf.sg2.ContentType; - import org.w3.x2005.x08.addressing.EndpointReferenceType; - - import de.fzj.unicore.uas.Registry; - import de.fzj.unicore.uas.UAS; - import de.fzj.unicore.uas.client.BaseUASClient; - - public class RegistryUtil { - - /** - * add an entry to the registy configured for UAS - * - * @param memberEpr - * @param content - * @throws Exception - * @return the epr of the new sg entry - */ - public static EndpointReferenceType addRegistryEntry(EndpointReferenceType memberEpr, - ContentType content) throws Exception{ - EndpointReferenceType registryEpr=UAS.getRegistryEpr(); - - BaseUASClient c=new BaseUASClient(registryEpr.getAddress().getStringValue(), - registryEpr, - UAS.getSecurityProperties()); - Registry reg=(Registry)c.makeProxy(Registry.class); - AddDocument in=AddDocument.Factory.newInstance(); - in.addNewAdd().setContent(content); - in.getAdd().setMemberEPR(memberEpr); - AddResponseDocument res=reg.Add(in); - return res.getAddResponse().getServiceGroupEntryReference(); - } - - public static EndpointReferenceType addRegistryEntry(EndpointReferenceType memberEpr) throws Exception{ - ContentType content=ContentType.Factory.newInstance(); - content.setNil(); - return addRegistryEntry(memberEpr,content); - } - - } --- 0 ---- Index: CreateSMSOnStartup.java =================================================================== RCS file: /cvsroot/unicore/unicore6/uas/src/main/java/de/fzj/unicore/uas/util/CreateSMSOnStartup.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CreateSMSOnStartup.java 8 Sep 2006 12:33:48 -0000 1.3 --- CreateSMSOnStartup.java 31 Oct 2006 14:26:10 -0000 1.4 *************** *** 43,46 **** --- 43,47 ---- import de.fzj.unicore.uas.UAS; + import de.fzj.unicore.uas.impl.registry.RegistryHandler; import de.fzj.unicore.uas.impl.sms.StorageManagementImpl; import de.fzj.unicore.wsrflite.Home; *************** *** 67,71 **** public CreateSMSOnStartup(){ ! registryEpr=UAS.getRegistryEpr(); logger.info("Using registry at "+registryEpr.getAddress().getStringValue()); } --- 68,72 ---- public CreateSMSOnStartup(){ ! registryEpr=RegistryHandler.getRegistryEpr(); logger.info("Using registry at "+registryEpr.getAddress().getStringValue()); } *************** *** 75,78 **** --- 76,86 ---- Home smsHome=Kernel.getKernel().getServiceHome(UAS.SMS); if(smsHome!=null){ + //check if instance already exists + try{ + if(smsHome.getWSRFServiceInstance(INSTANCE_ID)!=null)return; + }catch(Exception e){ + //ok, does not exist + } + Map<String,Object>map=new HashMap<String,Object>(); map.put(WSResourceImpl.INIT_UNIQUE_ID,INSTANCE_ID); *************** *** 94,98 **** AddressingUtil.addUGSRefparamToEpr(epr1,INSTANCE_ID); //store ! try{RegistryUtil.addRegistryEntry(epr1); logger.info("Added SMS instance reference to registry."); }catch(Exception e){ --- 102,106 ---- AddressingUtil.addUGSRefparamToEpr(epr1,INSTANCE_ID); //store ! try{RegistryHandler.getRegistryClient().addRegistryEntry(epr1); logger.info("Added SMS instance reference to registry."); }catch(Exception e){ Index: AddressingUtil.java =================================================================== RCS file: /cvsroot/unicore/unicore6/uas/src/main/java/de/fzj/unicore/uas/util/AddressingUtil.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AddressingUtil.java 21 Aug 2006 14:23:17 -0000 1.2 --- AddressingUtil.java 31 Oct 2006 14:26:10 -0000 1.3 *************** *** 55,59 **** public static void addUGSRefparamToEpr(EndpointReferenceType epr){ ! String resid=epr.getAddress().getStringValue().split("=")[1]; addUGSRefparamToEpr(epr,resid); } --- 55,61 ---- public static void addUGSRefparamToEpr(EndpointReferenceType epr){ ! String[] tokens=epr.getAddress().getStringValue().split("="); ! String resid = ""; ! if(tokens.length > 1) resid = tokens[1]; addUGSRefparamToEpr(epr,resid); } |