Package de.zib.scalaris

Examples of de.zib.scalaris.TransactionSingleOp$ResultList


        System.out.println("Reading values with the class `TransactionSingleOp`:");

        try {
            System.out.println("  creating object...");
            final TransactionSingleOp sc = new TransactionSingleOp();
            System.out
                    .println("    `OtpErlangObject readObject(OtpErlangString)`...");
            otpValue = (OtpErlangString) sc.read(otpKey).value();
            System.out.println("      read(" + otpKey.stringValue() + ") == "
                    + otpValue.stringValue());
        } catch (final ConnectionException e) {
            System.out.println("      read(" + otpKey.stringValue()
                    + ") failed: " + e.getMessage());
        } catch (final TimeoutException e) {
            System.out.println("      read(" + otpKey.stringValue()
                    + ") failed with timeout: " + e.getMessage());
        } catch (final NotFoundException e) {
            System.out.println("      read(" + otpKey.stringValue()
                    + ") failed with not found: " + e.getMessage());
        } catch (final ClassCastException e) {
            System.out.println("      read(" + otpKey.stringValue()
                    + ") failed with unexpected return type: " + e.getMessage());
        } catch (final UnknownException e) {
            System.out.println("      read(" + otpKey.stringValue()
                    + ") failed with unknown: " + e.getMessage());
        }

        try {
            System.out.println("  creating object...");
            final TransactionSingleOp sc = new TransactionSingleOp();
            System.out.println("    `String read(String)`...");
            value = sc.read(key).stringValue();
            System.out.println("      read(" + key + ") == " + value);
        } catch (final ConnectionException e) {
            System.out.println("      read(" + key + ") failed: "
                    + e.getMessage());
        } catch (final TimeoutException e) {
View Full Code Here


        System.out.println("Writing values with the class `TransactionSingleOp`:");

        try {
            System.out.println("  creating object...");
            final TransactionSingleOp sc = new TransactionSingleOp();
            System.out
                    .println("    `void writeObject(OtpErlangString, OtpErlangObject)`...");
            sc.write(otpKey, otpValue);
            System.out.println("      write(" + otpKey.stringValue() + ", "
                    + otpValue.stringValue() + ") succeeded");
        } catch (final ConnectionException e) {
            System.out.println("      write(" + otpKey.stringValue() + ", "
                    + otpValue.stringValue() + ") failed: " + e.getMessage());
        } catch (final TimeoutException e) {
            System.out.println("      write(" + otpKey.stringValue() + ", "
                    + otpValue.stringValue() + ") failed with timeout: "
                    + e.getMessage());
        } catch (final AbortException e) {
            System.out.println("      write(" + otpKey.stringValue() + ", "
                    + otpValue.stringValue() + ") failed with abort: "
                    + e.getMessage());
        } catch (final UnknownException e) {
            System.out.println("      write(" + otpKey.stringValue() + ", "
                    + otpValue.stringValue() + ") failed with unknown: "
                    + e.getMessage());
        }

        try {
            System.out.println("  creating object...");
            final TransactionSingleOp sc = new TransactionSingleOp();
            System.out.println("    `void write(String, String)`...");
            sc.write(key, value);
            System.out.println("      write(" + key + ", " + value
                    + ") succeeded");
        } catch (final ConnectionException e) {
            System.out.println("      write(" + key + ", " + value
                    + ") failed: " + e.getMessage());
View Full Code Here

    private void init(ConnectionFactory cFactory) throws RuntimeException {
        try {
            for (int i = 0; i < MAX_SCALARIS_CONNECTIONS; ++i) {
                Connection connection = cFactory.createConnection(
                        "wiki_import", true);
                scalaris_single.put(new TransactionSingleOp(connection));
                connection = cFactory.createConnection(
                        "wiki_import", true);
                scalaris_tx.put(new Transaction(connection));
            }
        } catch (ConnectionException e) {
View Full Code Here

     * @throws RuntimeException
     */
    @Override
    protected void doExport(SiteInfo siteinfo) throws RuntimeException {
        String key = ScalarisDataHandler.getSiteInfoKey();
        TransactionSingleOp scalaris_single;
        try {
            scalaris_single = this.scalaris_single.take();
        } catch (InterruptedException e) {
            System.err.println("write of " + key + " interrupted while getting connection to Scalaris");
            throw new RuntimeException(e);
        }
        try {
            scalaris_single.write(key, siteinfo);
        } catch (ConnectionException e) {
            System.err.println("write of " + key + " failed with connection error");
        } catch (TimeoutException e) {
            System.err.println("write of " + key + " failed with timeout");
        } catch (AbortException e) {
View Full Code Here

            this.note = note;
        }
       
        @Override
        public void run() {
            TransactionSingleOp scalaris_single;
            try {
                scalaris_single = this.scalaris_single.take();
            } catch (InterruptedException e) {
                System.err.println("write of " + note + " interrupted while getting connection to Scalaris");
                throw new RuntimeException(e);
            }
            try {
                TransactionSingleOp.ResultList results = scalaris_single.req_list(requests);
                for (int i = 0; i < results.size(); ++i) {
                    results.processWriteAt(i);
                }
            } catch (ConnectionException e) {
                System.err.println("write of " + note + " failed with connection error");
View Full Code Here

        try {
            for (int i = 0; i < MAX_SCALARIS_CONNECTIONS; ++i) {
                Connection connection = cFactory.createConnection(
                        "wiki_import", true);
                scalaris_single.put(new TransactionSingleOp(connection));
            }
        } catch (ConnectionException e) {
            System.err.println("Connection to Scalaris failed");
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
View Full Code Here

        if (connection == null) {
            return new PageHistoryResult(false, "no connection to Scalaris",
                    true, statName, System.currentTimeMillis() - timeAtStart);
        }
       
        TransactionSingleOp scalaris_single = new TransactionSingleOp(connection);
        TransactionSingleOp.RequestList requests = new TransactionSingleOp.RequestList();
        requests.addRead(getPageKey(title, nsObject)).addRead(getRevListKey(title, nsObject));
       
        TransactionSingleOp.ResultList results;
        try {
            results = scalaris_single.req_list(requests);
        } catch (Exception e) {
            return new PageHistoryResult(false, "unknown exception reading \""
                    + getPageKey(title, nsObject) + "\" or \""
                    + getRevListKey(title, nsObject) + "\" from Scalaris: "
                    + e.getMessage(), e instanceof ConnectionException,
View Full Code Here

            return new RevisionResult(false, "no connection to Scalaris", true,
                    page, revision, false, false, title,
                    System.currentTimeMillis() - timeAtStart);
        }
       
        TransactionSingleOp scalaris_single;
        String scalaris_key;
       
        scalaris_single = new TransactionSingleOp(connection);

        scalaris_key = getPageKey(title, nsObject);
        try {
            page = scalaris_single.read(scalaris_key).jsonValue(Page.class);
        } catch (NotFoundException e) {
            return new RevisionResult(false, "page not found at \""
                    + scalaris_key + "\"", false, page, revision, true, false,
                    title, System.currentTimeMillis() - timeAtStart);
        } catch (Exception e) {
            return new RevisionResult(false, "unknown exception reading \""
                    + scalaris_key + "\" from Scalaris: " + e.getMessage(),
                    e instanceof ConnectionException, page, revision, false,
                    false, title, System.currentTimeMillis() - timeAtStart);
        }

        // load requested version if it is not the current one cached in the Page object
        if (id != page.getCurRev().getId() && id >= 0) {
            scalaris_key = getRevKey(title, id, nsObject);
            try {
                revision = scalaris_single.read(scalaris_key).jsonValue(Revision.class);
            } catch (NotFoundException e) {
                return new RevisionResult(false, "revision not found at \""
                        + scalaris_key + "\"", false, page, revision, false,
                        true, title, System.currentTimeMillis() - timeAtStart);
            } catch (Exception e) {
View Full Code Here

        if (connection == null) {
            return new ValueResult<List<String>>(false, "no connection to Scalaris", true,
                    statName, System.currentTimeMillis() - timeAtStart);
        }
       
        TransactionSingleOp scalaris_single = new TransactionSingleOp(connection);
        try {
            List<String> pages = scalaris_single.read(scalaris_key).stringListValue();
            return new ValueResult<List<String>>(pages, statName,
                    System.currentTimeMillis() - timeAtStart);
        } catch (NotFoundException e) {
            if (failNotFound) {
                return new ValueResult<List<String>>(false,
View Full Code Here

        if (connection == null) {
            return new ValueResult<BigInteger>(false, "no connection to Scalaris",
                    true, statName, System.currentTimeMillis() - timeAtStart);
        }
       
        TransactionSingleOp scalaris_single = new TransactionSingleOp(connection);
        try {
            BigInteger number = scalaris_single.read(scalaris_key).bigIntValue();
            return new ValueResult<BigInteger>(number, statName,
                    System.currentTimeMillis() - timeAtStart);
        } catch (NotFoundException e) {
            if (failNotFound) {
                return new ValueResult<BigInteger>(false,
View Full Code Here

TOP

Related Classes of de.zib.scalaris.TransactionSingleOp$ResultList

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.