Package com.taobao.metamorphosis.network

Examples of com.taobao.metamorphosis.network.BooleanCommand


                }
                success = true;
                return new MessageIterator(fetchRequest.getTopic(), data);
            }
            else {
                final BooleanCommand booleanCmd = (BooleanCommand) response;
                switch (booleanCmd.getCode()) {
                case HttpStatus.NotFound:
                    success = true;
                    return null;
                case HttpStatus.Forbidden:
                    success = true;
                    return null;
                case HttpStatus.Moved:
                    success = true;
                    fetchRequest.resetRetries();
                    fetchRequest.setOffset(Long.parseLong(booleanCmd.getErrorMsg()), -1, true);
                    return null;
                default:
                    throw new MetaClientException("Status:" + booleanCmd.getCode() + ",Error message:"
                            + ((BooleanCommand) response).getErrorMsg());
                }
            }

        }
View Full Code Here



    public StatsResult getStats(String item, long timeout) {
        StatsResult statsResult = new StatsResult(this.serverUrl);
        try {
            BooleanCommand resp =
                    (BooleanCommand) this.remotingClient.invokeToGroup(this.serverUrl,
                        new StatsCommand(OpaqueGenerator.getNextOpaque(), item), timeout, TimeUnit.MILLISECONDS);

            final String resultStr = resp.getErrorMsg();

            switch (resp.getCode()) {
            case HttpStatus.Success: {
                statsResult.setSuccess(true);
                statsResult.setStatsInfo(resultStr);
                break;
            }
View Full Code Here

        MetaStatLog.addStat(null, StatConstants.TX_PREPARE);

        final TransactionInfo info =
                new TransactionInfo(x, this.sessionId, TransactionInfo.TransactionType.PREPARE, this.uniqueQualifier);

        final BooleanCommand response = this.syncSendXATxCommand(info);
        final int result = Integer.parseInt(response.getErrorMsg());
        if (XAResource.XA_RDONLY == result) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("XA_RDONLY from prepare: " + xid);
            }
        }
View Full Code Here

                throw new XAException(XAException.XAER_RMFAIL);
            }
            // Recover from all XA resources.
            for (final String serverUrl : this.xareresourceURLs) {
                try {
                    final BooleanCommand receipt =
                            (BooleanCommand) this.remotingClient.invokeToGroup(serverUrl, new TransactionCommand(info,
                                OpaqueGenerator.getNextOpaque()), this.transactionRequestTimeoutInMills,
                                TimeUnit.MILLISECONDS);
                    if (receipt.getCode() != HttpStatus.Success) {
                        log.warn("Recover XAResource(" + serverUrl + ") failed,error message:" + receipt.getErrorMsg());
                        continue;
                    }
                    final String data = receipt.getErrorMsg();
                    if (StringUtils.isBlank(data)) {
                        continue;
                    }
                    final String[] xidStrs = NEW_LINE_PATTERN.split(data);
                    for (final String key : xidStrs) {
View Full Code Here

    static Pattern EXCEPTION_PAT = Pattern.compile("code=(-?\\d+),msg=(.*)");


    private BooleanCommand syncSendXATxCommand(final TransactionInfo info) throws XAException {
        try {
            final BooleanCommand resp =
                    (BooleanCommand) this.remotingClient.invokeToGroup(this.serverUrl, new TransactionCommand(info,
                        OpaqueGenerator.getNextOpaque()), this.transactionRequestTimeoutInMills, TimeUnit.MILLISECONDS);
            if (resp.getResponseStatus() != ResponseStatus.NO_ERROR) {
                final String msg = resp.getErrorMsg();
                if (msg.startsWith("XAException:")) {
                    final Matcher m = EXCEPTION_PAT.matcher(msg);
                    if (m.find()) {
                        final int code = Integer.parseInt(m.group(1));
                        final String error = m.group(2);
View Full Code Here


    private void syncSendLocalTxCommand(final TransactionInfo info) throws MetaClientException, TimeoutException {
        try {

            final BooleanCommand resp =
                    (BooleanCommand) this.remotingClient.invokeToGroup(this.serverUrl, new TransactionCommand(info,
                        OpaqueGenerator.getNextOpaque()), this.transactionRequestTimeoutInMills, TimeUnit.MILLISECONDS);
            if (resp.getResponseStatus() != ResponseStatus.NO_ERROR) {
                throw new MetaClientException(resp.getErrorMsg());
            }
        }
        catch (TimeoutException te) {
            throw te;
        }
View Full Code Here

            for (String group : groups) {
                if (!group.equals(Constants.DEFAULT_GROUP)) {
                    URI uri = new URI(group);
                    InetSocketAddress sockAddr = new InetSocketAddress(uri.getHost(), uri.getPort());
                    if (target == null || target.equals(sockAddr)) {
                        BooleanCommand resp =
                                (BooleanCommand) this.remotingClient.invokeToGroup(group, new StatsCommand(
                                    OpaqueGenerator.getNextOpaque(), item), STATS_OPTIMEOUT, TimeUnit.MILLISECONDS);
                        if (resp.getResponseStatus() == ResponseStatus.NO_ERROR) {
                            String body = resp.getErrorMsg();
                            if (body != null) {
                                this.parseStatsValues(sockAddr, rt, group, body);
                            }
                        }
                    }
View Full Code Here

    @Override
    public ResponseCommand invokeToGroup(final String group, final RequestCommand command, final long time,
            final TimeUnit timeUnit) throws InterruptedException, TimeoutException, NotifyRemotingException {
        ResponseCommand resp = this.remotingClient.invokeToGroup(group, command, time, timeUnit);
        if (resp.getResponseStatus() == ResponseStatus.ERROR_COMM) {
            BooleanCommand booleanCommand = (BooleanCommand) resp;
            // It's ugly,but it work right now.
            if (booleanCommand.getErrorMsg().contains("�޿�������")) {
                // try to connect it.
                this.connectWithRef(group, this);
            }
        }
        return resp;
View Full Code Here

            final int flag = MessageFlagUtils.getFlag(message);
            final PutCommand putCommand =
                    new PutCommand(topic, partition.getPartition(), encodedData, flag, CheckSum.crc32(encodedData),
                        this.getTransactionId(), OpaqueGenerator.getNextOpaque());
            final BooleanCommand resp = this.invokeToGroup(serverUrl, partition, putCommand, message, timeout, unit);
            return this.genSendResult(message, partition, serverUrl, resp);
        }
        catch (final TimeoutException e) {
            throw new MetaOpeartionTimeoutException("Send message timeout in "
                    + TimeUnit.MILLISECONDS.convert(timeout, unit) + " mills");
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.network.BooleanCommand

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.