Package com.addthis.meshy

Examples of com.addthis.meshy.VirtualFileReference


            }
            if (files == null) {
                return;
            }
            while (files.hasNext()) {
                VirtualFileReference next = files.next();
                if (path.push(next.getName())) {
                    walkSafe(state, vfsKey, next, path);
                    state.dirs++;
                    path.pop();
                }
            }
        } else {
            long mark = debugCacheLine > 0 ? System.currentTimeMillis() : 0;
            String pathString = null;
            if (dirCacheSize > 0) { // if skipping questionable dir cache, then skip unused concurrency
                pathString = Strings.cat(vfsKey, ":", path.getRealPath(), "[", token, "]");
            /* this allows synchronizing on the path String */
                synchronized (pathStrings) {
                    String interned = pathStrings.get(pathString);
                    if (interned == null) {
                        pathStrings.put(pathString, pathString);
                        interned = pathString;
                    }
                    pathString = interned;
                }
                VFSDirCacheLine cacheLine = null;
            /* create "directory" cache line if missing */
                synchronized (cache) {
                    cacheLine = cache.get(pathString);
                    if (cacheLine == null || !cacheLine.isValid()) {
                        if (log.isTraceEnabled()) {
                            log.trace("new cache-line for " + pathString + " was " + cacheLine);
                        }
                        cacheLine = new VFSDirCacheLine(ref);
                        cache.put(pathString, cacheLine);
                    } else {
                        if (log.isTraceEnabled()) {
                            log.trace("old cache-line for " + pathString + " = " + cacheLine);
                        }
                        cacheHits.incrementAndGet();
                        cacheHitsMeter.mark();
                    }
                }
            /* prevent same query from multiple clients simultaneously */
                synchronized (cacheLine) {
                /* use cache-line if not empty */
                    if (!cacheLine.lines.isEmpty()) {
                        for (FileReference cacheRef : cacheLine.lines) {
                            if (log.isTraceEnabled()) {
                                log.trace("cache.send " + ref + " from " + cacheRef + " key=" + pathString);
                            }
                            send(cacheRef.encode(hostUuid));
                            found.incrementAndGet();
                            fileFindMeter.mark();
                        }
                        return;
                    }
                /* otherwise populate cache line */
                    Iterator<VirtualFileReference> files = ref.listFiles(filter);
                    if (log.isTraceEnabled()) {
                        log.trace("asDir=false filter=" + filter + " hostUuid=" + hostUuid + " files=" + files);
                    }
                    if (files == null) {
                        return;
                    }
                    while (files.hasNext()) {
                        VirtualFileReference next = files.next();
                        FileReference cacheRef = new FileReference(path.getRealPath(), next);
                        cacheLine.lines.add(cacheRef);
                        if (log.isTraceEnabled()) {
                            log.trace("local.send " + cacheRef + " cache to " + pathString + " in " + cacheLine.hashCode());
                        }
                        send(cacheRef.encode(hostUuid));
                        found.incrementAndGet();
                        fileFindMeter.mark();
                    }
                }
            } else {
                Iterator<VirtualFileReference> files = ref.listFiles(filter);
                if (log.isTraceEnabled()) {
                    log.trace("asDir=false filter=" + filter + " hostUuid=" + hostUuid + " files=" + files);
                }
                if (files == null) {
                    return;
                }
                while (files.hasNext()) {
                    VirtualFileReference next = files.next();
                    FileReference cacheRef = new FileReference(path.getRealPath(), next);
                    send(cacheRef.encode(hostUuid));
                    found.incrementAndGet();
                    fileFindMeter.mark();
                }
View Full Code Here


    private VirtualFileReference locateFile(VirtualFileSystem vfs, String path) {
        if (log.isTraceEnabled()) {
            log.trace("locate " + vfs + " --> " + path);
        }
        String tokens[] = vfs.tokenizePath(path);
        VirtualFileReference fileRef = vfs.getFileRoot();
        for (String token : tokens) {
            fileRef = fileRef.getFile(token);
            if (fileRef == null) {
                if (log.isTraceEnabled()) {
                    log.trace("no file " + vfs + " --> " + path + " --> " + fileRef);
                }
                return null;
View Full Code Here

                        String val = Bytes.readString(in);
                        params.put(key, val);
                    }
                }
                if (nodeUuid.equals(getChannelMaster().getUUID())) {
                    VirtualFileReference ref = null;
                    for (VirtualFileSystem vfs : getChannelMaster().getFileSystems()) {
                        ref = locateFile(vfs, fileName);
                        if (ref != null) {
                            fileIn = ref.getInput(params);
                            if (fileIn == null && log.isDebugEnabled()) {
                                log.debug("null file :: vfs=" + vfs.getClass().getName() + " ref=" + ref + " param=" + params + " fileIn=" + fileIn);
                            }
                            break;
                        }
View Full Code Here

    }

    private static VirtualFileReference locateFile(VirtualFileSystem vfs, String path) {
        log.trace("locate {} --> {}", vfs, path);
        String[] tokens = vfs.tokenizePath(path);
        VirtualFileReference fileRef = vfs.getFileRoot();
        for (String token : tokens) {
            fileRef = fileRef.getFile(token);
            if (fileRef == null) {
                log.trace("no file {} --> {} --> {}", vfs, path, token);
                return null;
            }
        }
View Full Code Here

                        String val = Bytes.readString(in);
                        params.put(key, val);
                    }
                }
                if (nodeUuid.equals(getChannelMaster().getUUID())) {
                    VirtualFileReference ref = null;
                    for (VirtualFileSystem vfs : getChannelMaster().getFileSystems()) {
                        ref = locateFile(vfs, fileName);
                        if (ref != null) {
                            fileIn = ref.getInput(params);
                            if (fileIn == null && log.isDebugEnabled()) {
                                log.debug("null file :: vfs={} ref={} param={} fileIn={}",
                                        vfs.getClass().getName(), ref, params, fileIn);
                            }
                            break;
View Full Code Here

    }

    private static VirtualFileReference locateFile(VirtualFileSystem vfs, String path) {
        log.trace("locate {} --> {}", vfs, path);
        String[] tokens = vfs.tokenizePath(path);
        VirtualFileReference fileRef = vfs.getFileRoot();
        for (String token : tokens) {
            fileRef = fileRef.getFile(token);
            if (fileRef == null) {
                log.trace("no file {} --> {} --> {}", vfs, path, token);
                return null;
            }
        }
View Full Code Here

                        String val = Bytes.readString(in);
                        params.put(key, val);
                    }
                }
                if (nodeUuid.equals(getChannelMaster().getUUID())) {
                    VirtualFileReference ref = null;
                    for (VirtualFileSystem vfs : getChannelMaster().getFileSystems()) {
                        ref = locateFile(vfs, fileName);
                        if (ref != null) {
                            fileIn = ref.getInput(params);
                            if (fileIn == null && log.isDebugEnabled()) {
                                log.debug("null file :: vfs={} ref={} param={} fileIn={}",
                                        vfs.getClass().getName(), ref, params, fileIn);
                            }
                            break;
View Full Code Here

            }
            if (files == null) {
                return;
            }
            while (files.hasNext()) {
                VirtualFileReference next = files.next();
                if (path.push(next.getName())) {
                    walkSafe(state, vfsKey, next, path);
                    state.dirs++;
                    path.pop();
                }
            }
        } else {
            long mark = debugCacheLine > 0 ? System.currentTimeMillis() : 0;
            String pathString = null;
            if (dirCacheSize > 0) { // if skipping questionable dir cache, then skip unused concurrency
                pathString = Strings.cat(vfsKey, ":", path.getRealPath(), "[", token, "]");
            /* this allows synchronizing on the path String */
                synchronized (pathStrings) {
                    String interned = pathStrings.get(pathString);
                    if (interned == null) {
                        pathStrings.put(pathString, pathString);
                        interned = pathString;
                    }
                    pathString = interned;
                }
                VFSDirCacheLine cacheLine = null;
            /* create "directory" cache line if missing */
                synchronized (cache) {
                    cacheLine = cache.get(pathString);
                    if (cacheLine == null || !cacheLine.isValid()) {
                        if (log.isTraceEnabled()) {
                            log.trace("new cache-line for " + pathString + " was " + cacheLine);
                        }
                        cacheLine = new VFSDirCacheLine(ref);
                        cache.put(pathString, cacheLine);
                    } else {
                        if (log.isTraceEnabled()) {
                            log.trace("old cache-line for " + pathString + " = " + cacheLine);
                        }
                        cacheHits.incrementAndGet();
                        cacheHitsMeter.mark();
                    }
                }
            /* prevent same query from multiple clients simultaneously */
                synchronized (cacheLine) {
                /* use cache-line if not empty */
                    if (!cacheLine.lines.isEmpty()) {
                        for (FileReference cacheRef : cacheLine.lines) {
                            if (log.isTraceEnabled()) {
                                log.trace("cache.send " + ref + " from " + cacheRef + " key=" + pathString);
                            }
                            send(cacheRef.encode(hostUuid));
                            found.incrementAndGet();
                            fileFindMeter.mark();
                        }
                        return;
                    }
                /* otherwise populate cache line */
                    Iterator<VirtualFileReference> files = ref.listFiles(filter);
                    if (log.isTraceEnabled()) {
                        log.trace("asDir=false filter=" + filter + " hostUuid=" + hostUuid + " files=" + files);
                    }
                    if (files == null) {
                        return;
                    }
                    while (files.hasNext()) {
                        VirtualFileReference next = files.next();
                        FileReference cacheRef = new FileReference(path.getRealPath(), next);
                        cacheLine.lines.add(cacheRef);
                        if (log.isTraceEnabled()) {
                            log.trace("local.send " + cacheRef + " cache to " + pathString + " in " + cacheLine.hashCode());
                        }
                        send(cacheRef.encode(hostUuid));
                        found.incrementAndGet();
                        fileFindMeter.mark();
                    }
                }
            } else {
                Iterator<VirtualFileReference> files = ref.listFiles(filter);
                if (log.isTraceEnabled()) {
                    log.trace("asDir=false filter=" + filter + " hostUuid=" + hostUuid + " files=" + files);
                }
                if (files == null) {
                    return;
                }
                while (files.hasNext()) {
                    VirtualFileReference next = files.next();
                    FileReference cacheRef = new FileReference(path.getRealPath(), next);
                    send(cacheRef.encode(hostUuid));
                    found.incrementAndGet();
                    fileFindMeter.mark();
                }
View Full Code Here

    }

    private static VirtualFileReference locateFile(VirtualFileSystem vfs, String path) {
        log.trace("locate {} --> {}", vfs, path);
        String tokens[] = vfs.tokenizePath(path);
        VirtualFileReference fileRef = vfs.getFileRoot();
        for (String token : tokens) {
            fileRef = fileRef.getFile(token);
            if (fileRef == null) {
                log.trace("no file {} --> {} --> {}", vfs, path, token);
                return null;
            }
        }
View Full Code Here

                        String val = Bytes.readString(in);
                        params.put(key, val);
                    }
                }
                if (nodeUuid.equals(getChannelMaster().getUUID())) {
                    VirtualFileReference ref = null;
                    for (VirtualFileSystem vfs : getChannelMaster().getFileSystems()) {
                        ref = locateFile(vfs, fileName);
                        if (ref != null) {
                            fileIn = ref.getInput(params);
                            if (fileIn == null && log.isDebugEnabled()) {
                                log.debug("null file :: vfs={} ref={} param={} fileIn={}",
                                        vfs.getClass().getName(), ref, params, fileIn);
                            }
                            break;
View Full Code Here

TOP

Related Classes of com.addthis.meshy.VirtualFileReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.