All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nfsdb.journal.net.comsumer.JournalServerStateConsumer Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2014. Vlad Ilyushchenko
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nfsdb.journal.net.comsumer;

import com.nfsdb.journal.net.AbstractMutableObjectConsumer;
import com.nfsdb.journal.net.model.JournalServerState;

import java.nio.ByteBuffer;

public class JournalServerStateConsumer extends AbstractMutableObjectConsumer {

    private char lagPartitionNameChars[];

    @Override
    protected JournalServerState newInstance() {
        return new JournalServerState();
    }

    @Override
    protected void read(ByteBuffer buffer, JournalServerState obj) {
        obj.reset();
        obj.setSymbolTables(buffer.get() == 1);
        int partitionCount = buffer.getInt();

        obj.setNonLagPartitionCount(partitionCount);
        for (int i = 0; i < partitionCount; i++) {
            obj.addPartitionMetadata(buffer.getInt(), buffer.getLong(), buffer.getLong(), buffer.get());
        }

        int len = buffer.getChar();
        if (len > 0) {
            if (lagPartitionNameChars == null || lagPartitionNameChars.length < len) {
                lagPartitionNameChars = new char[len];
            }
            for (int i = 0; i < len; i++) {
                lagPartitionNameChars[i] = buffer.getChar();
            }
            obj.setLagPartitionName(new String(lagPartitionNameChars, 0, len));
        } else {
            obj.setLagPartitionName(null);
        }

        obj.setLagPartitionMetadata(buffer.getInt(), buffer.getLong(), buffer.getLong(), buffer.get());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy