Package com.taobao.metamorphosis.exception

Examples of com.taobao.metamorphosis.exception.MetaClientException


                return new SendResult(false, null, -1, resultStr);
            }
        }
        catch (final Exception e) {
            this.logger.error(e.getMessage(), e);
            throw new MetaClientException(e);
        }
        finally {
            final long duration = System.currentTimeMillis() - start;
            System.out.println(duration);
            MetaStatLog.addStatValue2(null, StatConstants.PUT_TIME_STAT, message.getTopic(), duration);
View Full Code Here


    }


    private void checkMessage(final Message message) throws MetaClientException {
        if (message == null) {
            throw new MetaClientException("Null message");
        }
        if (StringUtils.isBlank(message.getTopic())) {
            throw new MetaClientException("Blank topic");
        }
        if (message.getData() == null) {
            throw new MetaClientException("Null data");
        }
    }
View Full Code Here


    final private void checkRequest(final String topic, final Partition partition, final long offset, final int maxsize)
            throws MetaClientException {
        if (topic == null || topic.isEmpty()) {
            throw new MetaClientException("Topic null");
        }

        if (offset < 0) {
            throw new MetaClientException("Offset must be positive");
        }

        if (partition == null) {
            throw new MetaClientException("partition must be positive");
        }

        if (maxsize < 0) {
            throw new MetaClientException("maxsize must be positive");
        }
    }
View Full Code Here

            }
            else if (httpget.getStatusCode() == HttpStatus.NotFound) {
                return null;
            }
            else {
                throw new MetaClientException(httpget.getResponseBodyAsString());
            }

        }
        catch (final HttpException e) {
            logger.error(e.getMessage(), e);
            throw new MetaClientException(e);
        }
        catch (final IOException e) {
            logger.error(e.getMessage(), e);
            throw new MetaClientException(e);
        }
        finally {
            httpget.releaseConnection();
            final long duration = System.currentTimeMillis() - start;
            if (duration > 200) {
View Full Code Here

            this.httpclient.executeMethod(httpget);
            if (httpget.getStatusCode() == HttpStatus.Success) {
                return Long.parseLong(httpget.getResponseBodyAsString());
            }
            else {
                throw new MetaClientException(httpget.getResponseBodyAsString());
            }
        }
        catch (final HttpException e) {
            logger.error(e.getMessage(), e);
            throw new MetaClientException(e);
        }
        catch (final IOException e) {
            logger.error(e.getMessage(), e);
            throw new MetaClientException(e);
        }
        finally {
            httpget.releaseConnection();
            final long duration = System.currentTimeMillis() - start;
            if (duration > 200) {
View Full Code Here

                this.consumerLoadBalanceListeners.putIfAbsent(fetchManager, task);
        if (existsTask == null) {
            task.run();
        }
        else {
            throw new MetaClientException("Consumer has been already registed");
        }

    }
View Full Code Here

        this.producer.publish("test");
        EasyMock.expectLastCall();
        MessageBuilder builder = MessageBuilder.withTopic("test").withBody("hello world");
        SendResult rt = new SendResult(false, null, -1, "test");
        EasyMock.expect(this.producer.sendMessage(builder.build(this.messageBodyConverter))).andThrow(
            new MetaClientException("test"));

        this.control.replay();
        SendResult sent = this.tempalte.send(builder);
        assertFalse(sent.isSuccess());
        assertNotNull(sent.getErrorMessage());
View Full Code Here

        List<Partition> configPartitions = this.getConfigPartitions(topic);
        int configPartitionsNum = configPartitions.size();

        // ˳����Ϣû�����ù�����������Ϣ,���÷���Ϣ
        if (configPartitionsNum == 0) {
            throw new MetaClientException("There is no config partitions for topic " + topic
                    + ",maybe you don't config it at first?");
        }

        Partition selectedPartition = this.choosePartition(topic, configPartitions, message);
        if (selectedPartition == null) {
            throw new MetaClientException("selected null partition");
        }

        // ���÷�����Ϊ0,����˳����Ϣ��Ϊ����ʱû�п��÷���(����ֻ��һ̨������,������������),����Ϊ��û����topic,
        // ������Ϣд���ػ���
        if (availablePartitionNum == 0) {
            throw new AvailablePartitionNumException("selected partition[" + selectedPartition + "]for topic[" + topic
                    + "]can not write now");
        }

        // ���÷��������÷�����������ѡ�����ķ���,(�������û������,�׳��쳣�û��Լ�����)
        if (!configPartitions.contains(selectedPartition) && !partitions.contains(selectedPartition)) {
            throw new MetaClientException("invalid selected partition:" + selectedPartition
                    + ",config and availabe paritions not contains it");
        }

        // ���÷��������÷���������ѡ�����ķ���ʱ�ſ�д
        if (configPartitions.contains(selectedPartition) && partitions.contains(selectedPartition)) {
View Full Code Here

    private SelectPartitionResult trySelectPartition(Message message) throws MetaClientException {
        SelectPartitionResult result = new SelectPartitionResult();
        try {
            Partition partition = this.producer.selectPartition(message);
            if (partition == null) {
                throw new MetaClientException("selected null partition");
            }
            result.setSelectedPartition(partition);
            result.setPartitionWritable(true);
        }
        catch (AvailablePartitionNumException e) {
View Full Code Here

        SubscriberInfo info = this.topicSubcriberRegistry.get(topic);
        if (info == null) {
            info = new SubscriberInfo(messageListener, filter, maxSize);
            final SubscriberInfo oldInfo = this.topicSubcriberRegistry.putIfAbsent(topic, info);
            if (oldInfo != null) {
                throw new MetaClientException("Topic=" + topic + " has been subscribered");
            }
            return this;
        }
        else {
            throw new MetaClientException("Topic=" + topic + " has been subscribered");
        }
    }
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.exception.MetaClientException

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.