Package com.taobao.metamorphosis.network

Examples of com.taobao.metamorphosis.network.BooleanCommand


                    final String resultStr =
                            SamsaCommandProcessor.this.genPutResultString(this.partition, this.messageId,
                                this.appendOffset);
                    if (this.cb != null) {
                        this.cb
                        .putComplete(new BooleanCommand(HttpStatus.Success, resultStr, this.request.getOpaque()));
                    }
                }
                else if (this.masterSuccess) {
                    SamsaCommandProcessor.this.statsManager.statsPutFailed(this.request.getTopic(),
                        this.partitionString, 1);
                    String error =
                            String.format("Put message to [slave '%s'] [partition '%s'] failed",
                                SamsaCommandProcessor.this.slaveUrl, this.request.getTopic() + "-" + this.partition);
                    this.cb.putComplete(new BooleanCommand(HttpStatus.InternalServerError, error, this.request
                        .getOpaque()));
                }
                else if (this.slaveSuccess) {
                    SamsaCommandProcessor.this.statsManager.statsPutFailed(this.request.getTopic(),
                        this.partitionString, 1);
                    String error =
                            String.format("Put message to [master '%s'] [partition '%s'] failed",
                                SamsaCommandProcessor.this.brokerZooKeeper.getBrokerString(), this.request.getTopic()
                                + "-" + this.partition);
                    this.cb.putComplete(new BooleanCommand(HttpStatus.InternalServerError, error, this.request
                        .getOpaque()));
                }
            }
        }
View Full Code Here


            throws InterruptedException, TimeoutException, NotifyRemotingException {
        info.setUniqueQualifier(UNIQUE_QUALIFIER);
        EasyMock.expect(
            this.remotingClient.invokeToGroup(serverUrl, new TransactionCommand(info, OpaqueGenerator.getNextOpaque()),
                DEFAULT_REQ_TIMEOUT, TimeUnit.MILLISECONDS)).andReturn(
                    new BooleanCommand(HttpStatus.Success, result, 0));
    }
View Full Code Here

        OpaqueGenerator.resetOpaque();
        final int flag = MessageFlagUtils.getFlag(null);
        EasyMock.expect(
            this.remotingClient.invokeToGroup(url, new PutCommand(topic, partition.getPartition(), data, flag, CheckSum.crc32(data),
                null, Integer.MIN_VALUE), 3000, TimeUnit.MILLISECONDS)).andReturn(
                    new BooleanCommand(200, "1111 1 1024", Integer.MIN_VALUE));
        this.mocksControl.replay();
        assertEquals(0, message.getId());
        final SendResult sendResult = this.producer.sendMessage(message);

        this.mocksControl.verify();
View Full Code Here

                break;
            case PREPARE:
                final int rt = this.processor.prepareTransaction(context, xid);
                // prepare����践��
                RemotingUtils.response(conn,
                    new BooleanCommand(HttpStatus.Success, String.valueOf(rt), request.getOpaque()));
                break;
                // �ύ��,forget��rollback��ʱ����ͬ�����ã������ҪӦ��
            case COMMIT_ONE_PHASE:
                this.processor.commitTransaction(context, xid, true);
                this.responseOK(request, conn);
                break;
            case COMMIT_TWO_PHASE:
                this.processor.commitTransaction(context, xid, false);
                this.responseOK(request, conn);
                break;
            case FORGET:
                this.processor.forgetTransaction(context, xid);
                this.responseOK(request, conn);
                break;
            case ROLLBACK:
                this.processor.rollbackTransaction(context, xid);
                this.responseOK(request, conn);
                break;
            case RECOVER:
                final TransactionId[] xids =
                        this.processor.getPreparedTransactions(context, request.getTransactionInfo()
                            .getUniqueQualifier());
                final StringBuilder sb = new StringBuilder();
                boolean wasFirst = true;
                for (final TransactionId id : xids) {
                    if (wasFirst) {
                        sb.append(id.getTransactionKey());
                        wasFirst = false;
                    }
                    else {
                        sb.append("\r\n").append(id.getTransactionKey());
                    }
                }
                RemotingUtils
                .response(conn, new BooleanCommand(HttpStatus.Success, sb.toString(), request.getOpaque()));
                break;
            default:
                RemotingUtils.response(conn, new BooleanCommand(HttpStatus.InternalServerError, "Unknow transaction command type:" + request.getTransactionInfo().getType(),
                    request.getOpaque()));

            }
        }
        catch (final XAException e) {
View Full Code Here

    }


    private void responseError(final TransactionCommand request, final Connection conn, final Exception e) {
        RemotingUtils.response(conn,
            new BooleanCommand(HttpStatus.InternalServerError, e.getMessage(), request.getOpaque()));
    }
View Full Code Here

            new BooleanCommand(HttpStatus.InternalServerError, e.getMessage(), request.getOpaque()));
    }


    private void responseXAE(final TransactionCommand request, final Connection conn, final XAException e) {
        RemotingUtils.response(conn, new BooleanCommand(HttpStatus.InternalServerError, "XAException:code=" + e.errorCode + ",msg=" + e.getMessage(),
            request.getOpaque()));
    }
View Full Code Here

    static final Log log = LogFactory.getLog(TransactionProcessor.class);


    private void responseOK(final TransactionCommand request, final Connection conn) {
        RemotingUtils.response(conn, new BooleanCommand(HttpStatus.Success, null, request.getOpaque()));
    }
View Full Code Here

        if (this.slidingWindow.tryAcquireByLength(dataLength)) {// , timeout,
                                                                // unit
            try {
                super.remotingClient.sendToGroup(serverUrl, putCommand, new MessageSendCallBackListener(putCommand),
                    timeout, unit);
                return new BooleanCommand(HttpStatus.Success, "-1 " + putCommand.getPartition()
                        + " -1", putCommand.getOpaque());
            }
            catch (final NotifyRemotingException e) {
                this.slidingWindow.releaseByLenth(dataLength);
                if (e.getMessage().contains("������������") || e.getMessage().contains("������������CallBack����")) {
View Full Code Here

    private BooleanCommand processOverMessage(final Partition partition, final PutCommand putCommand,
            final Message message, final MetaMessageOverflowException e2) throws MetaMessageOverflowException {
        if (this.ignoreMessageProcessor != null) {
            // ���ܴ��������������سɹ�
            this.handleSendFailMessage(message);
            return new BooleanCommand(HttpStatus.Success, "-1 " + putCommand.getPartition()
                    + " -1", putCommand.getOpaque());
        }
        else {
            throw e2;
        }
View Full Code Here

            final long currentOffset = fetchRequest.getOffset();
            final OffsetCommand offsetCmd =
                    new OffsetCommand(fetchRequest.getTopic(), this.consumerConfig.getGroup(),
                        fetchRequest.getPartition(), currentOffset, OpaqueGenerator.getNextOpaque());
            final String serverUrl = fetchRequest.getBroker().getZKString();
            final BooleanCommand booleanCmd =
                    (BooleanCommand) this.remotingClient.invokeToGroup(serverUrl, offsetCmd,
                        this.consumerConfig.getFetchTimeoutInMills(), TimeUnit.MILLISECONDS);
            switch (booleanCmd.getCode()) {
            case HttpStatus.Success:
                success = true;
                return Long.parseLong(booleanCmd.getErrorMsg());
            default:
                throw new MetaClientException(booleanCmd.getErrorMsg());
            }
        }
        catch (final MetaClientException e) {
            throw e;
        }
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.