Examples of Calculator


Examples of org.apache.openejb.itest.failover.ejb.Calculator

            final Properties environment = new Properties();
            environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
            environment.put(Context.PROVIDER_URL, "ejbd://localhost:" + blue.getServerService("ejbd").getPort());

            final InitialContext context = new InitialContext(environment);
            final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");

            // Invoke BLUE a few times
            invoke(bean, 10, "blue");

            // Kill BLUE
            blue.kill();

            // Invocations should now fail (and not failover)
            try {
                bean.name();
                Assert.fail("Server should be down and failover not hooked up");
            } catch (final Exception e) {
                // pass
            }
        }

        // Now we start RED
        red.start(1, TimeUnit.MINUTES);

        // Wait for the reconnectDelay so GREEN can find RED
        Thread.sleep((long) (reconnectDelay.getTime(TimeUnit.MILLISECONDS) * 1.5));

        // Verify Failover is now functional

        {
            // RED was never started so GREEN never found any peers

            // Lets invoke GREEN then shut it down and verify we have
            // no other peers to invoke
            final StandaloneServer green = servers.get("green");
            final Properties environment = new Properties();
            environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
            environment.put(Context.PROVIDER_URL, "ejbd://localhost:" + green.getServerService("ejbd").getPort());

            final InitialContext context = new InitialContext(environment);
            final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");


            // Invoke GREEN a few times
            invoke(bean, 10, "green");

View Full Code Here

Examples of org.apache.openejb.itest.failover.ejb.Calculator

            final Properties environment = new Properties();
            environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
            environment.put(Context.PROVIDER_URL, "ejbd://localhost:" + blue.getServerService("ejbd").getPort());

            final InitialContext context = new InitialContext(environment);
            final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");

            // Invoke BLUE a few times
            invoke(bean, 10, "blue");

            // Kill BLUE
            blue.kill();

            // Invocations should now fail (and not failover)
            try {
                bean.name();
                Assert.fail("Server should be down and failover not hooked up");
            } catch (final Exception e) {
                // pass
            }
        }

        // Now we start RED
        red.start(1, TimeUnit.MINUTES);

        // Wait for the reconnectDelay so GREEN can find RED
        Thread.sleep((long) (reconnectDelay.getTime(TimeUnit.MILLISECONDS) * 1.5));

        // Verify Failover is now functional

        {
            // RED was never started so GREEN never found any peers

            // Lets invoke GREEN then shut it down and verify we have
            // no other peers to invoke
            final StandaloneServer green = servers.get("green");
            final Properties environment = new Properties();
            environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
            environment.put(Context.PROVIDER_URL, "ejbd://localhost:" + green.getServerService("ejbd").getPort());

            final InitialContext context = new InitialContext(environment);
            final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");


            // Invoke GREEN a few times
            invoke(bean, 10, "green");

View Full Code Here

Examples of org.apache.openejb.itest.failover.ejb.Calculator

        final Properties environment = new Properties();
        environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
        environment.put(Context.PROVIDER_URL, "ejbd://localhost:" + servers.values().iterator().next().getServerService("ejbd").getPort() + "/provider");

        final InitialContext context = new InitialContext(environment);
        final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");

        for (final Map.Entry<String, StandaloneServer> entry : servers.entrySet()) {
            final String name = entry.getKey();
            final StandaloneServer server = entry.getValue();
            final URI serverURI = server.getContext().get(URI.class);

            logger.info("Waiting for updated list");
            services.assertServices(10, TimeUnit.SECONDS, new CalculatorCallable(bean), 500);

            logger.info("Asserting balance");
            assertBalance(bean, services.get().size());

            logger.info("Shutting down " + name);
            server.kill();
            services.remove(serverURI);
        }

        logger.info("All Servers Shutdown");

        try {
            logger.info("Making one last request, expecting complete failover");

            final String name = bean.name();
            Assert.fail("Server should be destroyed: " + name);
        } catch (final EJBException e) {
            logger.info(String.format("Pass.  Request resulted in %s: %s", e.getCause().getClass().getSimpleName(), e.getMessage()));
            // good
        }
View Full Code Here

Examples of org.apache.openejb.itest.failover.ejb.Calculator

        final Properties environment = new Properties();
        environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
        environment.put(Context.PROVIDER_URL, "failover:ejbd://localhost:" + servers.get(0).getServerService("ejbd").getPort());

        final InitialContext context = new InitialContext(environment);
        final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");

        for (final StandaloneServer server : servers) {
            System.out.println(String.format("Average invocation time %s microseconds", invoke(bean, 10000)));
            server.kill();
        }
View Full Code Here

Examples of org.apache.openejb.itest.failover.ejb.Calculator

        final Properties environment = new Properties();
        environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
        environment.put(Context.PROVIDER_URL, "ejbd://localhost:" + servers.values().iterator().next().getServerService("ejbd").getPort() + "/provider");

        final InitialContext context = new InitialContext(environment);
        final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");


        String previous = null;
        for (final StandaloneServer ignored : servers.values()) {

            logger.info("Looping");

            // What server are we talking to now?
            final String name = bean.name();

            logger.info("Sticky request to " + name);

            // The root should not be serving apps
            assertFalse("root".equals(name));

            // Should not be the same server we were talking with previously (we killed that server)
            if (previous != null) assertFalse(name.equals(previous));
            previous = name;

            final int i = 1000;

            logger.info(String.format("Performing %s invocations, expecting %s to be used for each invocation.", i, name));

            // Should be the same server for the next N calls
            invoke(bean, i, name);

            logger.info("Shutting down " + name);

            // Now let's kill that server
            servers.get(name).kill();
        }

        logger.info("All Servers Shutdown");

        try {
            logger.info("Making one last request, expecting complete failover");

            final String name = bean.name();
            Assert.fail("Server should be destroyed: " + name);
        } catch (final EJBException e) {
            logger.info(String.format("Pass.  Request resulted in %s: %s", e.getCause().getClass().getSimpleName(), e.getMessage()));
            // good
        }


        // Let's start a server again and invocations should now succeed
        final Iterator<StandaloneServer> iterator = servers.values().iterator();
        iterator.next();

        final StandaloneServer server = iterator.next();

        logger.info(String.format("Starting %s server", server.getProperties().get("name")));

        server.start(1, TimeUnit.MINUTES);

        logger.info("Performing one more invocation");

        assertEquals(5, bean.sum(2, 3));
    }
View Full Code Here

Examples of org.apache.openejb.itest.failover.ejb.Calculator

        final Properties environment = new Properties();
        environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
        environment.put(Context.PROVIDER_URL, "ejbd://localhost:" + server.getServerService("ejbd").getPort() + "/" + name);

        final InitialContext context = new InitialContext(environment);
        final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");
        assertEquals(name, bean.name());
    }
View Full Code Here

Examples of org.apache.openejb.itest.failover.ejb.Calculator

        final Properties environment = new Properties();
        environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
        environment.put(Context.PROVIDER_URL, "ejbd://localhost:" + servers.values().iterator().next().getServerService("ejbd").getPort() + "/provider");

        final InitialContext context = new InitialContext(environment);
        final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");

        for (final Map.Entry<String, StandaloneServer> entry : servers.entrySet()) {
            final String name = entry.getKey();
            final StandaloneServer server = entry.getValue();
            final URI serverURI = server.getContext().get(URI.class);

            logger.info("Waiting for updated list");
            services.assertServices(CLIENT_DELAY, TimeUnit.SECONDS, new CalculatorCallable(bean), 500);

            logger.info("Asserting balance");
            assertBalance(bean, services.get().size());

            logger.info("Shutting down " + name);
            server.kill();
            services.remove(serverURI);
        }

        logger.info("All Servers Shutdown");

        try {
            logger.info("Making one last request, expecting complete failover");

            final String name = bean.name();
            Assert.fail("Server should be destroyed: " + name);
        } catch (final EJBException e) {
            logger.info(String.format("Pass.  Request resulted in %s: %s", e.getCause().getClass().getSimpleName(), e.getMessage()));
            // good
        }
View Full Code Here

Examples of org.apache.openejb.itest.failover.ejb.Calculator

        final Properties environment = new Properties();
        environment.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
        environment.put(Context.PROVIDER_URL, "ejbd://localhost:" + servers.values().iterator().next().getServerService("ejbd").getPort() + "/provider");

        final InitialContext context = new InitialContext(environment);
        final Calculator bean = (Calculator) context.lookup("CalculatorBeanRemote");

        for (final Map.Entry<String, StandaloneServer> entry : servers.entrySet()) {
            final String name = entry.getKey();
            final StandaloneServer server = entry.getValue();
            final URI serverURI = server.getContext().get(URI.class);

            logger.info("Waiting for updated list");
            services.assertServices(1, TimeUnit.MINUTES, new CalculatorCallable(bean), 500);

            logger.info("Asserting balance");
            assertBalance(bean, services.get().size());

            logger.info("Shutting down " + name);
            server.kill();
            services.remove(serverURI);
        }

        logger.info("All Servers Shutdown");

        try {
            logger.info("Making one last request, expecting complete failover");

            final String name = bean.name();
            Assert.fail("Server should be destroyed: " + name);
        } catch (final EJBException e) {
            logger.info(String.format("Pass.  Request resulted in %s: %s", e.getCause().getClass().getSimpleName(), e.getMessage()));
            // good
        }
View Full Code Here

Examples of org.fenixedu.academic.domain.mobility.outbound.OutboundMobilityCandidacySubmission.Calculator

        final Set<Registration> processed = new HashSet<Registration>();
        for (final OutboundMobilityCandidacyContest contest : getOutboundMobilityCandidacyContestSet()) {
            for (final OutboundMobilityCandidacy candidacy : contest.getOutboundMobilityCandidacySet()) {
                final OutboundMobilityCandidacySubmission submission = candidacy.getOutboundMobilityCandidacySubmission();
                final Registration registration = submission.getRegistration();
                final Calculator calculator = new Calculator(registration.getStudent());

                if (!processed.contains(registration)) {
                    final Person person = registration.getPerson();

                    final Row row = spreadsheetCurricularInfo.addRow();
                    final BigDecimal candidacyGrade = submission.getGrade(this);
//                    final ICurriculum curriculum = registration.getCurriculum();
                    row.setCell(getString("label.username"), person.getUsername());
                    row.setCell(getString("label.name"), person.getName());
                    row.setCell(getString("label.degree"), registration.getDegree().getSigla());
                    row.setCell(getString("label.candidate.classification"),
                            candidacyGrade == null ? "" : candidacyGrade.toString());

                    row.setCell(getString("label.ects.first.cycle"), calculator.completedECTSCycle1.toString());
                    row.setCell(getString("label.ects.average"), calculator.getEctsAverage().toString());
                    row.setCell(getString("label.ects.average.first.and.second.cycle"), calculator
                            .getEctsEverateFirstAndSecondCycle().toString());
                    row.setCell(getString("label.ects.completed"), calculator.completedECTS.toString());
                    //row.setCell(getString("label.ects.pending"), calculator.getPendingEcts().toString());
                    row.setCell(getString("label.ects.enrolled"), calculator.enrolledECTS.toString());
View Full Code Here

Examples of org.hsqldb.cmdline.sqltool.Calculator

                            ? null : mathMatcher.group(3))));
                } else {
                    mathMatcher = mathPattern.matcher(initAssignmentStr);
                    if (mathMatcher.matches())
                        shared.userVars.put(mathMatcher.group(1), Long.toString(
                                new Calculator(((mathMatcher.groupCount() > 1
                                && mathMatcher.group(2) != null)
                                ? mathMatcher.group(2)
                                : ""), shared.userVars).reduce(0, false)));
                }
                sqlExpandMode = null;
            } catch (RuntimeException re) {
                throw new BadSpecial(SqltoolRB.math_expr_fail.getString(re));
            }
            String[] values =
                    logicalExprStr.substring(1, logicalExprStr.length() - 1)
                    .replaceAll("!([a-zA-Z0-9*])", "! $1").
                    replaceAll("([a-zA-Z0-9*])!", "$1 !").split("\\s+", -1);

            try {
                while (eval(values)) {
                    Recursion origRecursed = recursed;
                    recursed = Recursion.FOR;
                    try {
                        scanpass(token.nestedBlock.dup());
                    } catch (ContinueException ce) {
                        String ceMessage = ce.getMessage();

                        if (ceMessage != null && !ceMessage.equals("for"))
                            throw ce;
                    } finally {
                        recursed = origRecursed;
                    }
                    try {
                        Matcher mathMatcher =
                                mathAsgnPattern.matcher(iterableAssignmentStr);
                        if (mathMatcher.matches()) {
                            shared.userVars.put(
                                    mathMatcher.group(1), Long.toString(
                                    Calculator.reassignValue(
                                    mathMatcher.group(1),
                                    shared.userVars, mathMatcher.group(2),
                                    (mathMatcher.groupCount() < 3)
                                    ? null : mathMatcher.group(3))));
                        } else {
                            mathMatcher =
                                    mathPattern.matcher(iterableAssignmentStr);
                            if (mathMatcher.matches())
                                shared.userVars.put(
                                        mathMatcher.group(1), Long.toString(
                                        new Calculator(
                                        ((mathMatcher.groupCount() > 1
                                        && mathMatcher.group(2) != null)
                                        ? mathMatcher.group(2)
                                        : ""),
                                        shared.userVars).reduce(0, false)));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.