/** * Gets URL. * * @return entire SpaceFinder URL **/ public String getURL() { return getProperty(URL_NAME); }
/** * Remove the specified connection from the list of managed connections by this connection * factory. If it doesn't exist then fail silently * * @param connection connection to remove */ void removeConnection(GSConnectionImpl connection) { connectionsHash.remove(connection.connFacParent.getSpaceURL().getURL()); }
private void updateHostName(String value) { getCustomProperties().setProperty(XPathProperties.CONTAINER_JNDI_URL, value); String url = getProperty(URL_NAME); int lastSearchIndex = url.indexOf('?'); if (lastSearchIndex == -1) lastSearchIndex = url.length() - 1; //use here length of "java:" as fromIndex in order to reach //host url delimeter if exists int hostURLDelimeterIndex = url.lastIndexOf(":"); //if hist url delimeter exists ":" if (hostURLDelimeterIndex > 0 && hostURLDelimeterIndex < lastSearchIndex) { int lastHostURLIndex = url.indexOf("/", hostURLDelimeterIndex); int firstHostURLIndex = url.substring(0, lastHostURLIndex - 1).lastIndexOf("/"); if (firstHostURLIndex > 0 && lastHostURLIndex > firstHostURLIndex) { String oldValue = url.substring(firstHostURLIndex + 1, lastHostURLIndex); url = url.replaceFirst(oldValue, value); super.setProperty(URL_NAME, url); } } }
public void refreshUrlString() { final String oldUrl = getProperty(URL_NAME); final int suffixPos = oldUrl.indexOf('?'); final String suffix = suffixPos < 0 ? "" : oldUrl.substring(suffixPos); String newUrl = getProperty(PROTOCOL_NAME) + "//" + getProperty(HOST_NAME) + "/" + getContainerName() + "/" + getProperty(SPACE) + suffix; super.setProperty(URL_NAME, newUrl); }
public SpaceURL getMemberUrl(String memberName) { SpaceURL memberURL = _membersUrls.get(memberName); if (memberURL != null) return memberURL; memberURL = _spaceURL.clone(); String[] names = memberName.split(":"); memberURL.setContainerName(names[0]); memberURL.setSpaceName(names[1]); memberURL.refreshUrlString(); _membersUrls.put(memberName, memberURL); return memberURL; }
private static void initialize(SpaceURL spaceURL, String protocol, String containerName, String spaceName, String schemaName, String unicastHost) { spaceURL.setProperty(SpaceURL.PROTOCOL_NAME, protocol); spaceURL.setContainerName(containerName); spaceURL.setSpaceName(spaceName); spaceURL.setProperty(SpaceURL.MEMBER_NAME, containerName + ":" + spaceURL.getSpaceName()); if (schemaName != null && !spaceURL.containsKey(SpaceURL.SCHEMA_NAME)) spaceURL.setProperty(SpaceURL.SCHEMA_NAME, schemaName); spaceURL.setProperty(SpaceURL.HOST_NAME, unicastHost); if (!spaceURL.getProtocol().equalsIgnoreCase(SpaceURL.RMI_PROTOCOL)) { handleLocators(spaceURL); handleGroups(spaceURL); } if (spaceName != null) { if (!spaceURL.containsKey(SpaceURL.STATE)) spaceURL.setProperty(SpaceURL.STATE, JSpaceState.convertToString(ISpaceState.STARTED)); } }
private RemoteSpaceProxyLocator createProxyLocator(SpaceProxyImpl spaceProxy) { SpaceURL spaceUrl = spaceProxy.getFinderURL(); if (spaceUrl == null) spaceUrl = spaceProxy.getURL(); if (spaceUrl.isJiniProtocol()) { spaceUrl = spaceUrl.clone(); spaceUrl.remove(SpaceURL.USE_LOCAL_CACHE); } else { String url = SpaceUrlUtils.buildJiniUrl(spaceUrl.getContainerName(), spaceUrl.getSpaceName(), spaceUrl.getProperty(SpaceURL.GROUPS), null /*locators*/); try { spaceUrl = SpaceURLParser.parseURL(url); } catch (MalformedURLException e) { throw new ProxyInternalSpaceException(e); } } return new RemoteSpaceProxyLocator(spaceProxy.getName(), spaceUrl, quiesceTokenProvider); }
if (!SpaceURL.isValidProtocol(protocol)) throw new SpaceURLValidationException("Invalid space url - Unknown protocol found in space url: " + spaceURLStr); SpaceURL spaceURL = new SpaceURL(); spaceURL.initialize(spaceURLStr); spaceURL.setProperty(SpaceURL.MACHINE_HOSTNAME, machineName); boolean ignoreValidation = Boolean.valueOf(spaceURL.getProperty(SpaceURL.IGNORE_VALIDATION)); String propertiesFileName = spaceURL.getProperty(SpaceURL.PROPERTIES_FILE_NAME); if (!JSpaceUtilities.isEmpty(propFileName)) propertiesFileName = propFileName; spaceURL.getCustomProperties().putAll(customProperties); if (spaceURL.containsKey(SpaceURL.CLUSTER_SCHEMA) && !(spaceURL.containsKey(SpaceURL.SCHEMA_NAME))) { schemaName = SpaceURL.DEFAULT_SCHEMA_NAME; spaceURL.setProperty(SpaceURL.SCHEMA_NAME, schemaName); String clusterSchemaName = spaceURL.getProperty(SpaceURL.CLUSTER_SCHEMA); if (clusterSchemaName != null) { if (spaceURL.containsKey(SpaceURL.CLUSTER_MEMBER_ID)) { String memberID = spaceURL.getProperty(SpaceURL.CLUSTER_MEMBER_ID); String backupMemberID = spaceURL.getProperty(SpaceURL.CLUSTER_BACKUP_ID); if (backupMemberID != null) {
SpaceURL remoteSpaceURL = loadBalanceGroupMembersURLs.get(i).clone(); if (remoteSpaceURL.isJiniProtocol()) { SpaceURL anySpaceURL = remoteSpaceURL.clone(); anySpaceURL.setPropertiesPrefix(SpaceURL.JINI_PROTOCOL, SpaceURL.ANY, SpaceURL.ANY, SpaceURL.ANY); anySpaceURL.setProperty(SpaceURL.CLUSTER_NAME, clusterName); anySpaceURL.setProperty(SpaceURL.STATE, JSpaceState.convertToString(ISpaceState.STARTED)); if (remoteSpaceURL.getProperty(SpaceURL.HOST_NAME) != null && !SpaceURL.ANY.equals(remoteSpaceURL.getProperty(SpaceURL.HOST_NAME))) { remoteSpaceURL.setProperty(SpaceURL.CLUSTER_NAME, clusterName); remoteSpaceURL.setProperty(SpaceURL.STATE, JSpaceState.convertToString(ISpaceState.STARTED));
CredentialsProvider credentialsProvider, LifeCycle lifeCycle) throws Exception { final String spaceName = url.getSpaceName(); if (JSpaceUtilities.isEmpty(spaceName)) throw new FinderException("Using java:// protocol SpaceName should be defined in SpaceFinder URL"); final String containerName = url.getContainerName(); if (JSpaceUtilities.isEmpty(containerName)) throw new FinderException("Using java:// protocol ContainerName should be defined in SpaceFinder URL"); if (url.getProperty(SpaceURL.CREATE, "").equalsIgnoreCase("false")) throw new NoSuchNameException("Space <" + spaceName + "> could not be found using space url: " + url.getURL()); space = createEmbeddedSpace(containerName, url, customProperties, lifeCycle); _embeddedSpaces.put(url, space);
Properties customProperties = spaceURL.getCustomProperties(); String spaceURLLocators = spaceURL.getProperty(SpaceURL.LOCATORS); String spaceURLHosts = null; if (spaceURL.getHost() != null && spaceURL.isJiniProtocol()) spaceURLHosts = spaceURL.getHost(); (spaceURL.isJiniProtocol() && (!JSpaceUtilities.isEmpty(sysPropLocators, true) || !JSpaceUtilities.isEmpty(xpathLocators, true) || !JSpaceUtilities.isEmpty(spaceURLLocators, true))) || !spaceURL.isJiniProtocol(); spaceURL.setProperty(SpaceURL.LOCATORS, mergedLocatorsStr);
private SpaceURL convertReplicationGroupUrl(String memberLookupName) { final int position = _groupMembersNames.indexOf(memberLookupName); if (position == -1) return null; SpaceURL spaceUrl = _groupMembersUrls.get(position).clone(); if (JSpaceUtilities.isEmpty(spaceUrl.getProperty(SpaceURL.TIMEOUT))) spaceUrl.setProperty(SpaceURL.TIMEOUT, String.valueOf(_finderTimeout)); spaceUrl.setLookupAttribute(SpaceURL.STATE, new State().setReplicable(Boolean.TRUE)); return spaceUrl; } }
Properties custProps = null; if (_spaceURL != null) { custProps = _spaceURL.getCustomProperties(); String jiniGroup = _spaceURL.getProperty(SpaceURL.GROUPS); if (jiniGroup != null) mirrorConfig.serviceURL.setProperty(SpaceURL.GROUPS, jiniGroup); replPolicy.m_ReplicationGroupMembersNames.add(mirrorConfig.serviceURL.getMemberName()); replPolicy.m_ReplicationGroupMembersURLs.add(mirrorConfig.serviceURL); mirrorConfig.memberName = mirrorConfig.serviceURL.getMemberName();
public SpaceCopyStatus spaceCopy(IJSpace remoteProxy, Object template, boolean includeNotifyTemplates, int chunkSize) throws RemoteException { // verify that user can write on the local. IDirectSpaceProxy directProxy = (IDirectSpaceProxy) _spaceProxy; SpaceContext localSpaceContext = ((IDirectSpaceProxy) _spaceProxy).getSecurityManager().acquireContext(((IDirectSpaceProxy) _spaceProxy).getRemoteJSpace()); SpaceContext remoteSpaceContext = ((IDirectSpaceProxy) remoteProxy).getSecurityManager().acquireContext(((IDirectSpaceProxy) remoteProxy).getRemoteJSpace()); final IRemoteSpace remoteSpace = ((ISpaceProxy) remoteProxy).getDirectProxy().getRemoteJSpace(); final ObjectType objectType = ObjectType.fromObject(template); final ITemplatePacket templPacket = directProxy.getTypeManager().getTemplatePacketFromObject(template, objectType); String remoteUrl = "jini://*/" + remoteProxy.getContainerName() + "/" + remoteProxy.getName(); SpaceURL parseURL; try { parseURL = SpaceURLParser.parseURL(remoteUrl); } catch (MalformedURLException e) { throw new RemoteException("", e); } String groups = ((ISpaceProxy) remoteProxy).getDirectProxy().getProxySettings().getFinderURL().getProperty(SpaceURL.GROUPS); if (groups != null) parseURL.setProperty(SpaceURL.GROUPS, groups); String locators = ((ISpaceProxy) remoteProxy).getDirectProxy().getProxySettings().getFinderURL().getProperty(SpaceURL.LOCATORS); if (locators != null) parseURL.setProperty(SpaceURL.LOCATORS, locators); String remoteName = ((ISpaceProxy) remoteProxy).getDirectProxy().getRemoteMemberName(); return ((IInternalRemoteJSpaceAdmin) adminImpl).spaceCopy(remoteSpace, parseURL.getURL(), remoteName, templPacket, includeNotifyTemplates, chunkSize, localSpaceContext, remoteSpaceContext); }
@Override public synchronized boolean equals(Object obj) { if (obj instanceof SpaceURL) { SpaceURL other = (SpaceURL) obj; //check if space and container names, schema and cluster schema are equal //the rest of attributes are not taken into account while testing equality return JSpaceUtilities.isStringEquals(this.getContainerName(), other.getContainerName()) && JSpaceUtilities.isStringEquals(this.getSpaceName(), other.getSpaceName()) && JSpaceUtilities.isStringEquals(this.getSchema(), other.getSchema()) && JSpaceUtilities.isStringEquals(this.getClusterSchema(), other.getClusterSchema()) && isJiniGroupsEqual(other); } return false; }
private static Object findJiniSpace(SpaceURL url, String spaceUuid, Properties customProperties, long timeout, LookupType lookupType, boolean postProcess) throws FinderException { // NOTE, the Service.class should be used here as there is a special cache aside in GigaRegistrar based on it LookupRequest request = new LookupRequest(Service.class) .setLocators(url.getHost()) .setGroups(url.getProperty(SpaceURL.GROUPS)) .setCustomProperties(customProperties) .setTimeout(timeout) .setLookupInterval(url.getLookupIntervalTimeout()) .setLookupType(lookupType) .setSpaceUuid(spaceUuid); if(spaceUuid == null) request= request.setServiceAttributes(url.getLookupAttributes()); boolean previousLazyAccessValue = DefaultProxyPivot.updateLazyAccess(!postProcess); try { Object result = LookupFinder.find(request); if (postProcess) ((SpaceProxyImpl) result).setFinderURL(url); return result; } finally { DefaultProxyPivot.updateLazyAccess(previousLazyAccessValue); } }
/** * An overwrite method to set a SpaceURL property. This method adds to the super functionality * and intended to be the only method needs to be used to set SpaceURL properties (do not use * SpaceURL.concatAttrIfNotExist()). - It updates the space url string with the passed key and * appends it to the url string in case such does not exist. - If the passed key is one of the * generic lookup attributes, used for services lookup, it will update its values as well. - It * is also a chaining method which means you can call it several times and the set properties * will be appended and set appropriately into the current SpaceURL object. */ @Override public SpaceURL setProperty(String key, String value) { final String keyLower = key.toLowerCase(); //first we update the property itself. super.setProperty(keyLower, value); if (keyLower.equals(URL_NAME)) return this; if (AVAILABLE_URL_ATTRIBUTES.contains(keyLower)) { super.setProperty(URL_NAME, SpaceUrlUtils.setPropertyInUrl(getProperty(URL_NAME), key, value, true)); setLookupAttribute(keyLower, value); } else if (keyLower.equals(HOST_NAME)) updateHostName(value); return this;//for chaining method reasons }
Properties customProperties = spaceURL.getCustomProperties(); String customPropsGroups = customProperties.getProperty(XPathProperties.CONTAINER_JINI_LUS_GROUPS); sysPropGroups = JSpaceUtilities.removeInvertedCommas(sysPropGroups); String groups = spaceURL.getProperty(SpaceURL.GROUPS); if (!JSpaceUtilities.isEmpty(groups)) { spaceURL.setProperty(SpaceURL.GROUPS, JSpaceUtilities.removeInvertedCommas(mergedGroups)); spaceURL.setProperty(SpaceURL.GROUPS, mergedGroups); customProperties.setProperty(XPathProperties.CONTAINER_JINI_LUS_GROUPS, JSpaceUtilities.removeInvertedCommas(mergedGroups));
public ProxySettings setFinderURL(SpaceURL finderURL) { _finderURL = finderURL; if (finderURL != null && finderURL.getCustomProperties() != null) _customProperties.putAll(finderURL.getCustomProperties()); return this; }
public SpaceUrlBuilder(GigaSpace space) { SpaceURL finderURL = space.getSpace().getFinderURL(); this.locators = finderURL.getProperty("locators"); this.groups = finderURL.getProperty("groups"); this.versioned = Boolean.toString(space.getSpace().isOptimisticLockingEnabled()); this.spaceName = finderURL.getSpaceName(); }