Example usage for java.lang VirtualMachineError getMessage

List of usage examples for java.lang VirtualMachineError getMessage

Introduction

In this page you can find the example usage for java.lang VirtualMachineError getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.geode.cache.lucene.internal.cli.LuceneIndexCommands.java

@CliCommand(value = LuceneCliStrings.LUCENE_DESCRIBE_INDEX, help = LuceneCliStrings.LUCENE_DESCRIBE_INDEX__HELP)
@CliMetaData(relatedTopic = { CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA })
public Result describeIndex(
        @CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = true, help = LuceneCliStrings.LUCENE_DESCRIBE_INDEX__NAME__HELP) final String indexName,

        @CliOption(key = LuceneCliStrings.LUCENE__REGION_PATH, mandatory = true, optionContext = ConverterHint.REGION_PATH, help = LuceneCliStrings.LUCENE_DESCRIBE_INDEX__REGION_HELP) final String regionPath) {

    getSecurityService().authorize(Resource.CLUSTER, Operation.READ, LucenePermission.TARGET);

    try {/* www. ja v  a  2  s .  c om*/
        LuceneIndexInfo indexInfo = new LuceneIndexInfo(indexName, regionPath);
        return toTabularResult(getIndexDetails(indexInfo), true);
    } catch (FunctionInvocationTargetException ignore) {
        return ResultBuilder.createGemFireErrorResult(CliStrings.format(
                CliStrings.COULD_NOT_EXECUTE_COMMAND_TRY_AGAIN, LuceneCliStrings.LUCENE_DESCRIBE_INDEX));
    } catch (VirtualMachineError e) {
        SystemFailure.initiateFailure(e);
        throw e;
    } catch (IllegalArgumentException e) {
        return ResultBuilder.createInfoResult(e.getMessage());
    } catch (Throwable t) {
        SystemFailure.checkFailure();
        getCache().getLogger().info(t);
        return ResultBuilder.createGemFireErrorResult(String
                .format(LuceneCliStrings.LUCENE_DESCRIBE_INDEX__ERROR_MESSAGE, toString(t, isDebugging())));
    }
}

From source file:org.apache.geode.cache.lucene.internal.cli.LuceneIndexCommands.java

/**
 * Internally, we verify the resource operation permissions DATA:READ:[RegionName]
 *///from   w ww . java2s.  c om
@CliCommand(value = LuceneCliStrings.LUCENE_SEARCH_INDEX, help = LuceneCliStrings.LUCENE_SEARCH_INDEX__HELP)
@CliMetaData(relatedTopic = { CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA })
public Result searchIndex(
        @CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = true, help = LuceneCliStrings.LUCENE_SEARCH_INDEX__NAME__HELP) final String indexName,

        @CliOption(key = LuceneCliStrings.LUCENE__REGION_PATH, mandatory = true, optionContext = ConverterHint.REGION_PATH, help = LuceneCliStrings.LUCENE_SEARCH_INDEX__REGION_HELP) final String regionPath,

        @CliOption(key = { LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING,
                LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRINGS }, mandatory = true, help = LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING__HELP) final String queryString,

        @CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, mandatory = true, help = LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD__HELP) final String defaultField,

        @CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__LIMIT, unspecifiedDefaultValue = "-1", help = LuceneCliStrings.LUCENE_SEARCH_INDEX__LIMIT__HELP) final int limit,

        @CliOption(key = LuceneCliStrings.LUCENE_SEARCH_INDEX__KEYSONLY, unspecifiedDefaultValue = "false", help = LuceneCliStrings.LUCENE_SEARCH_INDEX__KEYSONLY__HELP) boolean keysOnly) {

    getSecurityService().authorize(Resource.DATA, Operation.READ, regionPath);

    try {
        LuceneQueryInfo queryInfo = new LuceneQueryInfo(indexName, regionPath, queryString, defaultField, limit,
                keysOnly);
        int pageSize = Integer.MAX_VALUE;
        searchResults = getSearchResults(queryInfo);
        return displayResults(pageSize, keysOnly);
    } catch (FunctionInvocationTargetException ignore) {
        return ResultBuilder.createGemFireErrorResult(CliStrings
                .format(CliStrings.COULD_NOT_EXECUTE_COMMAND_TRY_AGAIN, LuceneCliStrings.LUCENE_SEARCH_INDEX));
    } catch (VirtualMachineError e) {
        SystemFailure.initiateFailure(e);
        throw e;
    } catch (IllegalArgumentException e) {
        return ResultBuilder.createInfoResult(e.getMessage());
    } catch (GemFireSecurityException e) {
        throw e;
    } catch (Throwable t) {
        SystemFailure.checkFailure();
        getCache().getLogger().info(t);
        return ResultBuilder.createGemFireErrorResult(
                String.format(LuceneCliStrings.LUCENE_SEARCH_INDEX__ERROR_MESSAGE, toString(t, isDebugging())));
    }
}

From source file:org.apache.geode.cache.lucene.internal.cli.LuceneIndexCommands.java

@CliCommand(value = LuceneCliStrings.LUCENE_DESTROY_INDEX, help = LuceneCliStrings.LUCENE_DESTROY_INDEX__HELP)
@CliMetaData(relatedTopic = { CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA })
public Result destroyIndex(
        @CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, help = LuceneCliStrings.LUCENE_DESTROY_INDEX__NAME__HELP) final String indexName,

        @CliOption(key = LuceneCliStrings.LUCENE__REGION_PATH, mandatory = true, optionContext = ConverterHint.REGION_PATH, help = LuceneCliStrings.LUCENE_DESTROY_INDEX__REGION_HELP) final String regionPath) {

    if (StringUtils.isBlank(regionPath) || regionPath.equals(Region.SEPARATOR)) {
        return ResultBuilder.createInfoResult(
                CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__REGION_CANNOT_BE_EMPTY));
    }/*from  www  . j av  a 2s.c o m*/

    if (indexName != null && StringUtils.isEmpty(indexName)) {
        return ResultBuilder.createInfoResult(
                CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__INDEX_CANNOT_BE_EMPTY));
    }

    getSecurityService().authorize(Resource.CLUSTER, Operation.MANAGE, LucenePermission.TARGET);

    Result result;
    try {
        List<CliFunctionResult> accumulatedResults = new ArrayList<>();
        final XmlEntity xmlEntity = executeDestroyIndexFunction(accumulatedResults, indexName, regionPath);
        result = getDestroyIndexResult(accumulatedResults, indexName, regionPath);
        if (xmlEntity != null) {
            persistClusterConfiguration(result, () -> {
                // Delete the xml entity to remove the index(es) in all groups
                getSharedConfiguration().deleteXmlEntity(xmlEntity, null);
            });
        }
    } catch (FunctionInvocationTargetException ignore) {
        result = ResultBuilder.createGemFireErrorResult(CliStrings
                .format(CliStrings.COULD_NOT_EXECUTE_COMMAND_TRY_AGAIN, LuceneCliStrings.LUCENE_DESTROY_INDEX));
    } catch (VirtualMachineError e) {
        SystemFailure.initiateFailure(e);
        throw e;
    } catch (IllegalArgumentException e) {
        result = ResultBuilder.createInfoResult(e.getMessage());
    } catch (Throwable t) {
        t.printStackTrace();
        SystemFailure.checkFailure();
        getCache().getLogger().warning(LuceneCliStrings.LUCENE_DESTROY_INDEX__EXCEPTION_MESSAGE, t);
        result = ResultBuilder.createGemFireErrorResult(t.getMessage());
    }
    return result;
}

From source file:org.apache.geode.management.internal.beans.QueryDataFunction.java

private static Object callFunction(final Object functionArgs, final Set<DistributedMember> members,
        final boolean zipResult) throws Exception {

    try {//  w  ww  .java 2 s .  c o  m
        if (members.size() == 1) {
            DistributedMember member = members.iterator().next();
            ResultCollector collector = FunctionService.onMember(member).setArguments(functionArgs)
                    .execute(ManagementConstants.QUERY_DATA_FUNCTION);
            List list = (List) collector.getResult();
            Object object = null;
            if (list.size() > 0) {
                object = list.get(0);
            }

            if (object instanceof Throwable) {
                throw (Throwable) object;
            }

            QueryDataFunctionResult result = (QueryDataFunctionResult) object;
            if (zipResult) { // The result is already compressed
                return result.compressedBytes;
            } else {
                Object[] functionArgsList = (Object[]) functionArgs;
                boolean showMember = (Boolean) functionArgsList[DISPLAY_MEMBERWISE];
                if (showMember) {// Added to show a single member similar to multiple
                    // member.
                    // Note , if no member is selected this is the code path executed. A
                    // random associated member is chosen.
                    List<String> decompressedList = new ArrayList<>();
                    decompressedList.add(BeanUtilFuncs.decompress(result.compressedBytes));
                    return wrapResult(decompressedList.toString());
                }
                return BeanUtilFuncs.decompress(result.compressedBytes);
            }

        } else { // More than 1 Member
            ResultCollector coll = FunctionService.onMembers(members).setArguments(functionArgs)
                    .execute(ManagementConstants.QUERY_DATA_FUNCTION);

            List list = (List) coll.getResult();
            Object object = list.get(0);
            if (object instanceof Throwable) {
                throw (Throwable) object;
            }

            Iterator<QueryDataFunctionResult> it = list.iterator();
            List<String> decompressedList = new ArrayList<>();

            while (it.hasNext()) {
                String decompressedStr;
                decompressedStr = BeanUtilFuncs.decompress(it.next().compressedBytes);
                decompressedList.add(decompressedStr);
            }

            if (zipResult) {
                return BeanUtilFuncs.compress(wrapResult(decompressedList.toString()));
            } else {
                return wrapResult(decompressedList.toString());
            }

        }
    } catch (FunctionException fe) {
        throw new Exception(ManagementStrings.QUERY__MSG__QUERY_EXEC.toLocalizedString(fe.getMessage()));
    } catch (VirtualMachineError e) {
        SystemFailure.initiateFailure(e);
        throw e;
    } catch (Throwable e) {
        SystemFailure.checkFailure();
        throw new Exception(ManagementStrings.QUERY__MSG__QUERY_EXEC.toLocalizedString(e.getMessage()));
    }
}