Package com.taobao.common.store

Examples of com.taobao.common.store.Store


            @Override
            public Boolean call() throws Exception {
                final AtomicLong count = new AtomicLong(0);
                try {

                    final Store store = LocalMessageStorageManager.this.getOrCreateStore(topic, partition);

                    this.innerRecover(store, recoverer, count, name);
                }
                catch (final Throwable e) {
                    log.error("SendRecover������Ϣ�ָ�ʧ��,name=" + name, e);
                }
                finally {
                    log.info("SendRecoverִ������Ƴ����ͻָ�����,name=" + name + ",�ָ���Ϣ" + count.get() + "��");
                    LocalMessageStorageManager.this.topicRecoverTaskMap.remove(name);
                }
                return true;
            }


            private void innerRecover(final Store store, final MessageRecoverer recoverer, final AtomicLong count,
                    final String name) throws IOException, Exception {
                final Iterator<byte[]> it = store.iterator();
                while (it.hasNext()) {
                    final byte[] key = it.next();
                    final Message msg =
                            (Message) LocalMessageStorageManager.this.deserializer.decodeObject(store.get(key));
                    recoverer.handle(msg);
                    try {
                        store.remove(key);
                        count.incrementAndGet();
                        if (count.get() % 20000 == 0) {
                            log.info("SendRecover " + name + "�ѻָ���Ϣ����:" + count.get());
                        }
                    }
View Full Code Here


    @Override
    public void shutdown() {
        for (final Map.Entry<String, FutureTask<Store>> entry : this.topicStoreMap.entrySet()) {
            final String name = entry.getKey();
            final FutureTask<Store> task = entry.getValue();
            final Store store = this.getStore(name, task);
            try {
                store.close();
            }
            catch (final IOException e) {
                // ignore
            }
        }
View Full Code Here

    }


    @Override
    public void append(final Message message, final Partition partition) throws IOException {
        final Store store = this.getOrCreateStore(message.getTopic(), partition);
        final ByteBuffer buf = ByteBuffer.allocate(16);
        buf.putLong(this.idWorker.nextId());
        store.add(buf.array(), this.serializer.encodeObject(message));
    }
View Full Code Here

            @Override
            public Boolean call() throws Exception {
                try {
                    int count = 0;
                    Store randomPartitonStore =
                            OrderedLocalMessageStorageManager.this.getOrCreateStore(topic, Partition.RandomPartiton);

                    // ���ָܻ��ĸ����������Ȼָ�һ��δ֪����������(ԭ����,����������ݵIJ���ʱ���������ھ������)
                    // ������ͬһ��topic��δ֪�������лָ�������ᵼ�������ظ�����
                    if (randomPartitonStore.size() > 0) {
                        // ������ʱ�Ŷ�randomPartitonStoreͬ������
                        synchronized (randomPartitonStore) {
                            // ˫�ؼ��
                            if (randomPartitonStore.size() > 0) {
                                count = this.innerRecover(randomPartitonStore, recoverer);
                                log.info("SendRecover topic=" + topic + "@-1--1�ָ���Ϣ" + count + "��");
                            }
                        }
                    }

                    Store store = OrderedLocalMessageStorageManager.this.getOrCreateStore(topic, partition);

                    count = this.innerRecover(store, recoverer);
                    log.info("SendRecover topic=" + name + "�ָ���Ϣ" + count + "��");
                }
                catch (Throwable e) {
                    log.error("SendRecover������Ϣ�ָ�ʧ��,topic=" + name, e);
                }
                finally {
                    log.info("SendRecoverִ������Ƴ����ͻָ�����,topic=" + name);
                    OrderedLocalMessageStorageManager.this.topicRecoverTaskMap.remove(name);
                }
                return true;
            }


            private int innerRecover(Store store, final MessageRecoverer recoverer) throws IOException, Exception {
                Iterator<byte[]> it = store.iterator();
                int count = 0;
                while (it.hasNext()) {
                    byte[] key = it.next();
                    Message msg =
                            (Message) OrderedLocalMessageStorageManager.this.deserializer.decodeObject(store.get(key));
                    recoverer.handle(msg);
                    try {
                        store.remove(key);
                        count++;
                    }
                    catch (IOException e) {
                        log.error("SendRecover remove message failed", e);
                    }
View Full Code Here

                    final String name = entry.getKey();
                    final String[] tmps = name.split(SPLIT);
                    final String topic = tmps[0];
                    final String group = tmps[1];
                    final FutureTask<Store> task = entry.getValue();
                    final Store store = RecoverStorageManager.this.getStore(topic, task);
                    try {
                        final MessageListener listener =
                                RecoverStorageManager.this.subscribeInfoManager.getMessageListener(topic, group);
                        final Iterator<byte[]> it = store.iterator();
                        int count = 0;
                        while (it.hasNext()) {
                            final byte[] key = it.next();
                            final Message msg =
                                    (Message) RecoverStorageManager.this.deserializer.decodeObject(store.get(key));
                            if (msg != null) {
                                RecoverStorageManager.this.receiveMessage(store, key, msg, listener);
                            }
                            count++;
                        }
View Full Code Here

        for (final Map.Entry<String, FutureTask<Store>> entry : this.topicStoreMap.entrySet()) {
            final String name = entry.getKey();
            final String[] tmps = name.split(SPLIT);
            final String topic = tmps[0];
            final FutureTask<Store> task = entry.getValue();
            final Store store = this.getStore(topic, task);
            try {
                store.close();
            }
            catch (final IOException e) {
                // ignore
            }
        }
View Full Code Here

    }


    @Override
    public void append(final String group, final Message message) throws IOException {
        final Store store = this.getOrCreateStore(message.getTopic(), group);
        long key = message.getId();
        IOException error = null;
        for (int i = 0; i < 5; i++) {
            try {
                final ByteBuffer buf = ByteBuffer.allocate(16);
                buf.putLong(key);
                store.add(buf.array(), this.serializer.encodeObject(message));
                return;
            }
            catch (final IOException e) {
                final String msg = e.getMessage();
                // key�ظ�
View Full Code Here

TOP

Related Classes of com.taobao.common.store.Store

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.