Package voldemort.store.readonly

Examples of voldemort.store.readonly.ReadOnlyStorageEngine$KeyValueLocation


            if(!Utils.isReadableDir(storeDir))
                throw new VoldemortException("Could not read folder " + storeDir
                                             + " correctly to delete it");

            final ReadOnlyStorageEngine store = getReadOnlyStorageEngine(metadataStore,
                                                                         storeRepository,
                                                                         storeName);

            if(store.getCurrentVersionId() == ReadOnlyUtils.getVersionId(new File(storeDir))) {
                logger.warn("Cannot delete " + storeDir + " for " + storeName
                            + " since it is the current dir");
                return response.build();
            }
View Full Code Here


        final String storeName = request.getStoreName();
        final long pushVersion = request.getPushVersion();
        VAdminProto.RollbackStoreResponse.Builder response = VAdminProto.RollbackStoreResponse.newBuilder();

        try {
            ReadOnlyStorageEngine store = getReadOnlyStorageEngine(metadataStore,
                                                                   storeRepository,
                                                                   storeName);

            File rollbackVersionDir = new File(store.getStoreDirPath(), "version-" + pushVersion);

            logger.info("Rolling back data for RO store '" + storeName + "' to version directory '"
                        + rollbackVersionDir + "'");
            store.rollback(rollbackVersionDir);
            logger.info("Successfully rolled back data for RO store '" + storeName
                        + "' to version directory '" + rollbackVersionDir + "'");
        } catch(VoldemortException e) {
            response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
            logger.error("handleRollbackStore failed for request(" + request.toString() + ")", e);
View Full Code Here

     * @return The directory path which was swapped out
     * @throws VoldemortException
     */
    private String swapStore(String storeName, String directory) throws VoldemortException {

        ReadOnlyStorageEngine store = getReadOnlyStorageEngine(metadataStore,
                                                               storeRepository,
                                                               storeName);

        if(!Utils.isReadableDir(directory))
            throw new VoldemortException("Store directory '" + directory
                                         + "' is not a readable directory.");

        String currentDirPath = store.getCurrentDirPath();

        logger.info("Swapping RO store '" + storeName + "' to version directory '" + directory
                    + "'");
        store.swapFiles(directory);
        logger.info("Swapping swapped RO store '" + storeName + "' to version directory '"
                    + directory + "'");

        return currentDirPath;
    }
View Full Code Here

            if(!metadataStore.getReadOnlyFetchEnabledUnlocked()) {
                throw new VoldemortException("Read-only fetcher is disabled in "
                                             + metadataStore.getServerStateUnlocked()
                                             + " state on node " + metadataStore.getNodeId());
            }
            final ReadOnlyStorageEngine store = getReadOnlyStorageEngine(metadataStore,
                                                                         storeRepository,
                                                                         storeName);
            final long pushVersion;
            if(request.hasPushVersion()) {
                pushVersion = request.getPushVersion();
                if(pushVersion <= store.getCurrentVersionId())
                    throw new VoldemortException("Version of push specified (" + pushVersion
                                                 + ") should be greater than current version "
                                                 + store.getCurrentVersionId() + " for store "
                                                 + storeName + " on node "
                                                 + metadataStore.getNodeId());
            } else {
                // Find the max version
                long maxVersion;
                File[] storeDirList = ReadOnlyUtils.getVersionDirs(new File(store.getStoreDirPath()));
                if(storeDirList == null || storeDirList.length == 0) {
                    throw new VoldemortException("Push version required since no version folders exist for store "
                                                 + storeName
                                                 + " on node "
                                                 + metadataStore.getNodeId());
                } else {
                    maxVersion = ReadOnlyUtils.getVersionId(ReadOnlyUtils.findKthVersionedDir(storeDirList,
                                                                                              storeDirList.length - 1,
                                                                                              storeDirList.length - 1)[0]);
                }
                pushVersion = maxVersion + 1;
            }

            asyncService.submitOperation(requestId, new AsyncOperation(requestId, "Fetch store") {

                private String fetchDirPath = null;

                @Override
                public void markComplete() {
                    if(fetchDirPath != null)
                        status.setStatus(fetchDirPath);
                    status.setComplete(true);
                }

                @Override
                public void operate() {

                    File fetchDir = null;

                    if(fileFetcher == null) {

                        logger.warn("File fetcher class has not instantiated correctly. Assuming local file");

                        if(!Utils.isReadableDir(fetchUrl)) {
                            throw new VoldemortException("Fetch url " + fetchUrl
                                                         + " is not readable");
                        }

                        fetchDir = new File(store.getStoreDirPath(), "version-"
                                                                     + Long.toString(pushVersion));

                        if(fetchDir.exists())
                            throw new VoldemortException("Version directory "
                                                         + fetchDir.getAbsolutePath()
                                                         + " already exists");

                        Utils.move(new File(fetchUrl), fetchDir);

                    } else {

                        logger.info("Started executing fetch of " + fetchUrl + " for RO store '"
                                    + storeName + "'");
                        updateStatus("0 MB copied at 0 MB/sec - 0 % complete");
                        try {
                            fileFetcher.setAsyncOperationStatus(status);
                            fetchDir = fileFetcher.fetch(fetchUrl, store.getStoreDirPath()
                                                                   + File.separator + "version-"
                                                                   + Long.toString(pushVersion));
                            if(fetchDir == null) {
                                String errorMessage = "File fetcher failed for "
                                                      + fetchUrl
View Full Code Here

                                                                                                  storeName);

                        EventThrottler throttler = new EventThrottler(voldemortConfig.getStreamMaxWriteBytesPerSec());

                        if(isReadOnlyStore) {
                            ReadOnlyStorageEngine readOnlyStorageEngine = ((ReadOnlyStorageEngine) storageEngine);
                            String destinationDir = readOnlyStorageEngine.getCurrentDirPath();
                            logger.info("Fetching files for RO store '" + storeName
                                        + "' from node " + nodeId + " ( " + partitionIds + " )");
                            updateStatus("Fetching files for RO store '" + storeName
                                         + "' from node " + nodeId + " ( " + partitionIds + " )");

                            adminClient.readonlyOps.fetchPartitionFiles(nodeId,
                                                                        storeName,
                                                                        partitionIds,
                                                                        destinationDir,
                                                                        readOnlyStorageEngine.getChunkedFileSet()
                                                                                             .getChunkIdToNumChunks()
                                                                                             .keySet(),
                                                                        running);

                        } else {
View Full Code Here

            if(!Utils.isReadableDir(dir))
                throw new ServletException("Could not read folder " + dir
                                           + " correctly to delete it");

            ReadOnlyStorageEngine store = this.getStore(storeName);
            if(store.getCurrentVersionId() == ReadOnlyUtils.getVersionId(new File(dir))) {
                logger.warn("Cannot delete " + dir + " for " + storeName
                            + " since it is the current dir");
                return;
            }
View Full Code Here

           && !metadataStore.getServerStateUnlocked()
                            .equals(MetadataStore.VoldemortState.OFFLINE_SERVER)) {
            throw new ServletException("Voldemort server is neither in normal state nor in offline state");
        }

        ReadOnlyStorageEngine store = this.getStore(storeName);
        if(store == null)
            throw new ServletException("'" + storeName + "' is not a registered read-only store.");

        if(!Utils.isReadableDir(dir))
            throw new ServletException("Store directory '" + dir + "' is not a readable directory.");

        // Retrieve the current directory before swapping it
        String currentDirPath = store.getCurrentDirPath();

        // Swap with the new directory
        store.swapFiles(dir);

        // Send back the previous directory
        resp.getWriter().write(currentDirPath);
    }
View Full Code Here

            ServletException {
        String fetchUrl = getRequired(req, "dir");
        String storeName = getRequired(req, "store");
        String pushVersionString = getOptional(req, "pushVersion");

        ReadOnlyStorageEngine store = this.getStore(storeName);
        if(store == null)
            throw new ServletException("'" + storeName + "' is not a registered read-only store.");

        long pushVersion;
        if(pushVersionString == null) {
            // Find the max version
            long maxVersion;
            File[] storeDirList = ReadOnlyUtils.getVersionDirs(new File(store.getStoreDirPath()));
            if(storeDirList == null || storeDirList.length == 0) {
                throw new ServletException("Push version required since no version folders exist");
            } else {
                maxVersion = ReadOnlyUtils.getVersionId(ReadOnlyUtils.findKthVersionedDir(storeDirList,
                                                                                          storeDirList.length - 1,
                                                                                          storeDirList.length - 1)[0]);
            }
            pushVersion = maxVersion + 1;
        } else {
            pushVersion = Long.parseLong(pushVersionString);
            if(pushVersion <= store.getCurrentVersionId())
                throw new ServletException("Version of push specified (" + pushVersion
                                           + ") should be greater than current version "
                                           + store.getCurrentVersionId());
        }

        // fetch the files if necessary
        File fetchDir = null;
        if(fileFetcher == null) {

            logger.warn("File fetcher class has not instantiated correctly. Assuming local file");

            if(!Utils.isReadableDir(fetchUrl)) {
                throw new ServletException("Fetch url " + fetchUrl + " is not readable");
            }

            fetchDir = new File(store.getStoreDirPath(), "version-" + Long.toString(pushVersion));

            if(fetchDir.exists())
                throw new ServletException("Version directory " + fetchDir.getAbsolutePath()
                                           + " already exists");

            Utils.move(new File(fetchUrl), fetchDir);

        } else {
            logger.info("Executing fetch of " + fetchUrl);

            try {
                fetchDir = fileFetcher.fetch(fetchUrl, store.getStoreDirPath() + File.separator
                                                       + "version-" + Long.toString(pushVersion));

                if(fetchDir == null) {
                    throw new ServletException("File fetcher failed for " + fetchUrl
                                               + " and store name = " + storeName
View Full Code Here

    private void doRollback(HttpServletRequest req) throws ServletException {
        String storeName = getRequired(req, "store");
        long pushVersion = Long.parseLong(getRequired(req, "pushVersion"));

        ReadOnlyStorageEngine store = getStore(storeName);
        if(store == null)
            throw new ServletException("'" + storeName + "' is not a registered read-only store.");

        try {
            File rollbackVersionDir = new File(store.getStoreDirPath(), "version-" + pushVersion);

            store.rollback(rollbackVersionDir);
        } catch(Exception e) {
            throw new ServletException("Exception in rollback = " + e.getMessage());
        }
    }
View Full Code Here

                    if(useSwappedStoreNames && !swappedStoreNames.contains(storeDef.getName())) {
                        continue;
                    }

                    ReadOnlyStorageEngine engine = (ReadOnlyStorageEngine) storeRepository.getStorageEngine(storeDef.getName());

                    if(engine == null) {
                        throw new VoldemortException("Could not find storage engine for "
                                                     + storeDef.getName() + " to swap ");
                    }

                    logger.info("Swapping RO store " + storeDef.getName());

                    // Time to swap this store - Could have used admin client,
                    // but why incur the overhead?
                    engine.swapFiles(engine.getCurrentDirPath());

                    // Add to list of stores already swapped
                    if(!useSwappedStoreNames)
                        swappedStoreNames.add(storeDef.getName());
                }
View Full Code Here

TOP

Related Classes of voldemort.store.readonly.ReadOnlyStorageEngine$KeyValueLocation

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.