Search in sources :

Example 6 with GemFireException

use of org.apache.geode.GemFireException in project geode by apache.

the class RebalanceOperationImpl method getResults.

public RebalanceResults getResults() throws CancellationException, InterruptedException {
    RebalanceResultsImpl results = new RebalanceResultsImpl();
    List<Future<RebalanceResults>> frlist = getFutureList();
    for (Future<RebalanceResults> fr : frlist) {
        try {
            RebalanceResults rr = fr.get();
            results.addDetails((RebalanceResultsImpl) rr);
        } catch (ExecutionException e) {
            if (e.getCause() instanceof GemFireException) {
                throw (GemFireException) e.getCause();
            } else if (e.getCause() instanceof InternalGemFireError) {
                throw (InternalGemFireError) e.getCause();
            } else {
                throw new InternalGemFireError(e.getCause());
            }
        }
    }
    return results;
}
Also used : GemFireException(org.apache.geode.GemFireException) Future(java.util.concurrent.Future) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) RebalanceResults(org.apache.geode.cache.control.RebalanceResults) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 7 with GemFireException

use of org.apache.geode.GemFireException in project geode by apache.

the class RebalanceOperationImpl method getResults.

public RebalanceResults getResults(long timeout, TimeUnit unit) throws CancellationException, TimeoutException, InterruptedException {
    long endTime = unit.toNanos(timeout) + System.nanoTime();
    RebalanceResultsImpl results = new RebalanceResultsImpl();
    List<Future<RebalanceResults>> frlist = getFutureList();
    for (Future<RebalanceResults> fr : frlist) {
        try {
            long waitTime = endTime - System.nanoTime();
            RebalanceResults rr = fr.get(waitTime, TimeUnit.NANOSECONDS);
            results.addDetails((RebalanceResultsImpl) rr);
        } catch (ExecutionException e) {
            if (e.getCause() instanceof GemFireException) {
                throw (GemFireException) e.getCause();
            } else if (e.getCause() instanceof InternalGemFireError) {
                throw (InternalGemFireError) e.getCause();
            } else {
                throw new InternalGemFireError(e.getCause());
            }
        }
    }
    return results;
}
Also used : GemFireException(org.apache.geode.GemFireException) Future(java.util.concurrent.Future) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) RebalanceResults(org.apache.geode.cache.control.RebalanceResults) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 8 with GemFireException

use of org.apache.geode.GemFireException in project geode by apache.

the class AbstractGatewaySenderEventProcessor method setRunningStatus.

public void setRunningStatus() throws Exception {
    GemFireException ex = null;
    try {
        this.initializeEventDispatcher();
    } catch (GemFireException e) {
        ex = e;
    }
    synchronized (this.runningStateLock) {
        if (ex != null) {
            this.setException(ex);
            setIsStopped(true);
        } else {
            setIsStopped(false);
        }
        this.runningStateLock.notifyAll();
    }
    if (ex != null) {
        throw ex;
    }
}
Also used : GemFireException(org.apache.geode.GemFireException)

Example 9 with GemFireException

use of org.apache.geode.GemFireException in project geode by apache.

the class JdkToolTest method testGetJdkToolPathnameForNonExistingTool.

@Test
public void testGetJdkToolPathnameForNonExistingTool() {
    try {
        final GemFireException expected = new GemFireException() {

            @Override
            public String getMessage() {
                return "expected";
            }
        };
        JdkTool.getJdkToolPathname("nonExistingTool.exe", expected);
    } catch (GemFireException expected) {
        assertEquals("expected", expected.getMessage());
    }
}
Also used : GemFireException(org.apache.geode.GemFireException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 10 with GemFireException

use of org.apache.geode.GemFireException in project geode by apache.

the class StartJConsoleCommand method startJConsole.

@CliCommand(value = CliStrings.START_JCONSOLE, help = CliStrings.START_JCONSOLE__HELP)
@CliMetaData(shellOnly = true, relatedTopic = { CliStrings.TOPIC_GEODE_MANAGER, CliStrings.TOPIC_GEODE_JMX, CliStrings.TOPIC_GEODE_M_AND_M })
public Result startJConsole(@CliOption(key = CliStrings.START_JCONSOLE__INTERVAL, unspecifiedDefaultValue = "4", help = CliStrings.START_JCONSOLE__INTERVAL__HELP) final int interval, @CliOption(key = CliStrings.START_JCONSOLE__NOTILE, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false", help = CliStrings.START_JCONSOLE__NOTILE__HELP) final boolean notile, @CliOption(key = CliStrings.START_JCONSOLE__PLUGINPATH, help = CliStrings.START_JCONSOLE__PLUGINPATH__HELP) final String pluginpath, @CliOption(key = CliStrings.START_JCONSOLE__VERSION, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false", help = CliStrings.START_JCONSOLE__VERSION__HELP) final boolean version, @CliOption(key = CliStrings.START_JCONSOLE__J, optionContext = GfshParser.J_OPTION_CONTEXT, help = CliStrings.START_JCONSOLE__J__HELP) final String[] jvmArgs) {
    try {
        String[] jconsoleCommandLine = createJConsoleCommandLine(null, interval, notile, pluginpath, version, jvmArgs);
        if (isDebugging()) {
            getGfsh().printAsInfo(String.format("JConsole command-line ($1%s)", Arrays.toString(jconsoleCommandLine)));
        }
        Process jconsoleProcess = Runtime.getRuntime().exec(jconsoleCommandLine);
        StringBuilder message = new StringBuilder();
        if (version) {
            jconsoleProcess.waitFor();
            BufferedReader reader = new BufferedReader(new InputStreamReader(jconsoleProcess.getErrorStream()));
            for (String line = reader.readLine(); line != null; line = reader.readLine()) {
                message.append(line);
                message.append(StringUtils.LINE_SEPARATOR);
            }
            IOUtils.close(reader);
        } else {
            getGfsh().printAsInfo(CliStrings.START_JCONSOLE__RUN);
            String jconsoleProcessOutput = waitAndCaptureProcessStandardErrorStream(jconsoleProcess);
            if (StringUtils.isNotBlank(jconsoleProcessOutput)) {
                message.append(StringUtils.LINE_SEPARATOR);
                message.append(jconsoleProcessOutput);
            }
        }
        return ResultBuilder.createInfoResult(message.toString());
    } catch (GemFireException | IllegalStateException | IllegalArgumentException e) {
        return ResultBuilder.createShellClientErrorResult(e.getMessage());
    } catch (IOException e) {
        return ResultBuilder.createShellClientErrorResult(CliStrings.START_JCONSOLE__IO_EXCEPTION_MESSAGE);
    } catch (VirtualMachineError e) {
        SystemFailure.initiateFailure(e);
        throw e;
    } catch (Throwable t) {
        SystemFailure.checkFailure();
        return ResultBuilder.createShellClientErrorResult(String.format(CliStrings.START_JCONSOLE__CATCH_ALL_ERROR_MESSAGE, toString(t, false)));
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) GemFireException(org.apache.geode.GemFireException) BufferedReader(java.io.BufferedReader) CliCommand(org.springframework.shell.core.annotation.CliCommand) CliMetaData(org.apache.geode.management.cli.CliMetaData)

Aggregations

GemFireException (org.apache.geode.GemFireException)12 ExecutionException (java.util.concurrent.ExecutionException)3 Future (java.util.concurrent.Future)3 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)3 CliMetaData (org.apache.geode.management.cli.CliMetaData)3 CliCommand (org.springframework.shell.core.annotation.CliCommand)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 InternalGemFireError (org.apache.geode.InternalGemFireError)2 ServerConnectivityException (org.apache.geode.cache.client.ServerConnectivityException)2 RebalanceResults (org.apache.geode.cache.control.RebalanceResults)2 InfoResultData (org.apache.geode.management.internal.cli.result.InfoResultData)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Iterator (java.util.Iterator)1 List (java.util.List)1 GemFireIOException (org.apache.geode.GemFireIOException)1