List of usage examples for java.net URI equals
public boolean equals(Object ob)
From source file:org.apache.hadoop.hdfs.server.namenode.AvatarStorageSetup.java
static void validate(Configuration conf, Collection<URI> namedirs, Collection<URI> editsdir, URI img0, URI img1, URI edit0, URI edit1) throws IOException { FLOG.info("Avatar conf validation - namedirs: " + namedirs); FLOG.info("Avatar conf validation - editdirs: " + editsdir); FLOG.info("Avatar conf validation - shared namedirs: " + img0 + ", " + img1); FLOG.info("Avatar conf validation - shared editdirs: " + edit0 + ", " + edit1); String msg = ""; if (conf == null) { msg += "Configuration should not be null. "; }// w ww .j av a 2 s .com if (img0 == null || img1 == null || edit0 == null || edit1 == null) { msg += "Configuration does not contain shared locations for image and edits. "; // at this point there we fail checkMessage(msg); } if (img0.equals(img1)) { msg += "Configuration contains the same image location for dfs.name.dir.shared0 " + "and dfs.name.dir.shared1"; // at this point there we fail checkMessage(msg); } if (edit0.equals(edit1)) { msg += "Configuration contains the same edits location for dfs.name.edits.dir.shared0 " + "and dfs.name.edits.dir.shared1"; // at this point there we fail checkMessage(msg); } // non-shared storage is file based msg += checkFileURIScheme(namedirs); msg += checkFileURIScheme(editsdir); // verify that the shared image dirctories are not specified as dfs.name.dir msg += checkContainment(namedirs, img0, "dfs.name.dir", "dfs.name.dir.shared0"); msg += checkContainment(namedirs, img1, "dfs.name.dir", "dfs.name.dir.shared1"); // verify that the shared edits directories are not specified as // dfs.name.edits.dir msg += checkContainment(editsdir, edit0, "dfs.name.edits.dir", "dfs.name.edits.dir.shared0"); msg += checkContainment(editsdir, edit1, "dfs.name.edits.dir", "dfs.name.edits.dir.shared1"); if (conf.get("dfs.name.dir.shared") != null || conf.get("dfs.name.edits.dir.shared") != null) { msg += " dfs.name.dir.shared and dfs.name.edits.dir.shared should not be set manually"; } // check shared image location msg += checkImageStorage(img0, edit0); msg += checkImageStorage(img1, edit1); checkMessage(msg); }
From source file:piecework.util.FormUtility.java
public static URI remoteHost(UserInterfaceSettings settings, ModelProvider modelProvider) throws PieceworkException { URI remoteHostUri = null; ProcessDeployment deployment = ModelUtility.deployment(modelProvider); String remoteHost = deployment != null ? deployment.getRemoteHost() : null; String serverHost = settings.getHostUri(); if (StringUtils.isNotEmpty(remoteHost) && StringUtils.isNotEmpty(serverHost)) { try {/*w w w . jav a2 s. c o m*/ remoteHostUri = new URI(remoteHost); URI serverHostUri = new URI(serverHost); // Don't return a remote host if in fact the remote host is the same as the server host // because it means that we're not doing CORS for this request if (remoteHostUri.equals(serverHostUri)) return null; } catch (URISyntaxException iae) { LOG.error("Failed to convert remote host or server host location into uri:" + remoteHost + ", " + serverHost, iae); } } return remoteHostUri; }
From source file:podd.util.iterator.ObjectFixedClosableIterator.java
private void getNextMatch() { while (iterator.hasNext()) { final T axiom = iterator.next(); final URI currentURI = axiom.getObject().getURI(); if (currentURI.equals(obj)) { currentAxiom = axiom;/*w w w . ja v a 2s . c o m*/ return; } } currentAxiom = null; }
From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtil.java
/** * Returns whether the parent path contains the child path, or not. * If the parent and child is same, this returns {@code false}. * @param parent the parent path/* www . j av a 2s . co m*/ * @param child the child path * @return {@code true} if parent path strictly contains the child, otherwise {@code false} * @throws IllegalArgumentException if some parameters were {@code null} */ public static boolean contains(Path parent, Path child) { if (parent == null) { throw new IllegalArgumentException("parent must not be null"); //$NON-NLS-1$ } if (child == null) { throw new IllegalArgumentException("child must not be null"); //$NON-NLS-1$ } if (parent.depth() >= child.depth()) { return false; } URI parentUri = parent.toUri(); URI childUri = child.toUri(); URI relative = parentUri.relativize(childUri); if (relative.equals(childUri) == false) { return true; } return false; }
From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtil.java
@SuppressWarnings("unchecked") private static List<Path> createFileListRelative(Counter counter, FileSystem fs, Path source) throws IOException { assert counter != null; assert fs != null; assert source != null; assert source.isAbsolute(); URI baseUri = source.toUri(); FileStatus root;/* w ww.j a v a 2 s.c om*/ try { root = fs.getFileStatus(source); } catch (FileNotFoundException e) { LOG.warn(MessageFormat.format("Source path is not found: {0} (May be already moved)", baseUri)); return Collections.emptyList(); } counter.add(1); List<FileStatus> all = recursiveStep(fs, Collections.singletonList(root)); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Source path contains {1} files/directories: {0}", //$NON-NLS-1$ baseUri, all.size())); } List<Path> results = new ArrayList<>(); for (FileStatus stat : all) { if (stat.isDirectory()) { continue; } Path path = stat.getPath(); URI uri = path.toUri(); URI relative = baseUri.relativize(uri); if (relative.equals(uri) == false) { results.add(new Path(relative)); } else { throw new IOException(MessageFormat.format("Failed to compute relative path: base={0}, target={1}", baseUri, uri)); } counter.add(1); } Collections.sort(results); return results; }
From source file:org.jenkinsci.plugins.scriptsecurity.scripts.ClasspathEntry.java
@Override @SuppressFBWarnings(value = "DMI_BLOCKING_METHODS_ON_URL", justification = "Method call has been optimized, but we still need URLs as a fallback") public boolean equals(Object obj) { if (!(obj instanceof ClasspathEntry)) { return false; }/*from w w w . j a v a2s .c om*/ // Performance optimization to avoid domain name resolution final ClasspathEntry cmp = (ClasspathEntry) obj; final URI uri = getURI(); return uri != null ? uri.equals(cmp.getURI()) : url.equals(cmp.url); }
From source file:uk.ac.ucl.cs.cmic.giftcloud.restserver.GiftCloudServer.java
public boolean matchesServer(final String giftCloudUrl) throws MalformedURLException { try {//from w w w. ja va 2s.co m final URI uri = new URI(giftCloudUrl); return (uri.equals(giftCloudUri)); } catch (URISyntaxException e) { throw new MalformedURLException("The GIFT-Cloud server name " + giftCloudUrl + " is not a valid URL."); } }
From source file:org.ldp4j.server.data.DataTransformatorTest.java
@Before public void setUp() throws Exception { sut = DataTransformator.create(APPLICATION_BASE).mediaType(new MediaType("text", "turtle")) .permanentEndpoint(NANDANA_ENDPOINT).enableResolution(new ResourceResolver() { @Override// w w w.j a v a 2s . c o m public URI resolveResource(ManagedIndividualId id) { if (id.equals(NANDANA_ID)) { return NANDANA_LOCATION; } return null; } @Override public ManagedIndividualId resolveLocation(URI path) { if (path.equals(NANDANA_LOCATION)) { return NANDANA_ID; } return null; } }); }
From source file:com.proofpoint.event.collector.combiner.CombinedGroup.java
public CombinedStoredObject getCombinedObject(URI location) { for (CombinedStoredObject combinedObject : combinedObjects) { if (location.equals(combinedObject.getLocation())) { return combinedObject; }//from w ww . ja va 2s . co m } return null; }
From source file:org.apache.hadoop.mapred.lib.MobiusDelegatingInputFormat.java
private String getDatasetIDBySplit(InputSplit split, JobConf conf) throws IOException { // The <code>split</code> is an instance of {@link TaggedInputSplit} // but the TaggedInputSplit is not a public class, so we need to place // this class under the package of org.apache.hadoop.mapred.lib. TaggedInputSplit taggedSplit = (TaggedInputSplit) split; InputSplit inputSplit = taggedSplit.getInputSplit(); URI currentFileURI = MultiInputsHelpersRepository.getInstance(conf).getURIBySplit(inputSplit, conf); String currentFile = currentFileURI.toString(); LOGGER.debug("Using [" + currentFile + "] to locate current Dataset"); String datasetID = null;//from w w w . j av a2s . c om for (URI anInput : _INPUT_URIS) { if (anInput.equals(currentFileURI)) { datasetID = _URI_TO_DATASETID_MAPPING.get(anInput); if (datasetID == null || datasetID.trim().length() == 0) throw new IllegalArgumentException( "Dataet ID for the input path:[" + anInput + "] did not set."); } else { // not equal, compute the relative URI URI relative = anInput.relativize(currentFileURI); if (!relative.equals(currentFileURI)) { // found the key datasetID = _URI_TO_DATASETID_MAPPING.get(anInput); if (datasetID == null || datasetID.trim().length() == 0) throw new IllegalArgumentException( "Dataet ID for the input path:[" + anInput + "] did not set."); } } } if (datasetID == null) { throw new IllegalArgumentException("Cannot find dataset id using the given uri:[" + currentFile + "], " + ConfigureConstants.INPUT_TO_DATASET_MAPPING + ":" + conf.get(ConfigureConstants.INPUT_TO_DATASET_MAPPING)); } return datasetID; }