Commit eaa02545 authored by peng-yongsheng's avatar peng-yongsheng
Browse files

Test success with standalone and cluster mode.

parent f3e85ef6
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -40,8 +40,11 @@ public class SegmentPost {
        serviceNameRegisterPost.send("json/servicename-register-provider.json");

        JsonElement provider = JsonFileReader.INSTANCE.read("json/dubbox-provider.json");
        HttpClientTools.INSTANCE.post("http://localhost:12800/segments", provider.toString());
        JsonElement consumer = JsonFileReader.INSTANCE.read("json/dubbox-consumer.json");

        for (int i = 0; i < 1000; i++) {
            HttpClientTools.INSTANCE.post("http://localhost:12800/segments", provider.toString());
            HttpClientTools.INSTANCE.post("http://localhost:12800/segments", consumer.toString());
        }
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import org.skywalking.apm.collector.agent.stream.service.register.IApplicationID
import org.skywalking.apm.collector.agent.stream.service.register.IInstanceIDService;
import org.skywalking.apm.collector.agent.stream.service.register.IServiceNameService;
import org.skywalking.apm.collector.agent.stream.service.trace.ITraceSegmentService;
import org.skywalking.apm.collector.agent.stream.worker.AgentStreamRemoteDataRegister;
import org.skywalking.apm.collector.agent.stream.worker.jvm.CpuMetricService;
import org.skywalking.apm.collector.agent.stream.worker.jvm.GCMetricService;
import org.skywalking.apm.collector.agent.stream.worker.jvm.InstanceHeartBeatService;
@@ -42,6 +43,8 @@ import org.skywalking.apm.collector.cache.CacheModule;
import org.skywalking.apm.collector.core.module.Module;
import org.skywalking.apm.collector.core.module.ModuleProvider;
import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
import org.skywalking.apm.collector.remote.RemoteModule;
import org.skywalking.apm.collector.remote.service.RemoteDataRegisterService;
import org.skywalking.apm.collector.storage.StorageModule;

/**
@@ -75,6 +78,10 @@ public class AgentStreamModuleProvider extends ModuleProvider {
    }

    @Override public void start(Properties config) throws ServiceNotProvidedException {
        RemoteDataRegisterService remoteDataRegisterService = getManager().find(RemoteModule.NAME).getService(RemoteDataRegisterService.class);
        AgentStreamRemoteDataRegister agentStreamRemoteDataRegister = new AgentStreamRemoteDataRegister(remoteDataRegisterService);
        agentStreamRemoteDataRegister.register();

        AgentStreamBootStartup bootStartup = new AgentStreamBootStartup(getManager());
        bootStartup.start();
    }
+6 −0
Original line number Diff line number Diff line
@@ -26,13 +26,19 @@ import java.util.Properties;
public class BufferFileConfig {
    static int BUFFER_OFFSET_MAX_FILE_SIZE = 10 * 1024 * 1024;
    static int BUFFER_SEGMENT_MAX_FILE_SIZE = 10 * 1024 * 1024;
    static String BUFFER_PATH = "../buffer/";

    private static final String BUFFER_PATH_KEY = "buffer_file_path";
    private static final String BUFFER_OFFSET_MAX_FILE_SIZE_KEY = "buffer_offset_max_file_size";
    private static final String BUFFER_SEGMENT_MAX_FILE_SIZE_KEY = "buffer_segment_max_file_size";

    public static class Parser {

        public void parse(Properties config) {
            if (config.containsKey(BUFFER_PATH_KEY)) {
                BUFFER_PATH = config.getProperty(BUFFER_PATH_KEY);
            }

            if (config.containsKey(BUFFER_OFFSET_MAX_FILE_SIZE_KEY)) {
                String sizeStr = config.getProperty(BUFFER_OFFSET_MAX_FILE_SIZE_KEY).toUpperCase();
                if (sizeStr.endsWith("K")) {
+3 −3
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public enum OffsetManager {
    public synchronized void initialize() throws IOException {
        if (!initialized) {
            this.offset = new Offset();
            File dataPath = new File(SegmentBufferConfig.BUFFER_PATH);
            File dataPath = new File(BufferFileConfig.BUFFER_PATH);
            if (dataPath.mkdirs()) {
                createOffsetFile();
            } else {
@@ -77,7 +77,7 @@ public enum OffsetManager {
    private void createOffsetFile() throws IOException {
        String timeBucket = String.valueOf(TimeBucketUtils.INSTANCE.getSecondTimeBucket(System.currentTimeMillis()));
        String offsetFileName = OFFSET_FILE_PREFIX + "_" + timeBucket + "." + Const.FILE_SUFFIX;
        offsetFile = new File(SegmentBufferConfig.BUFFER_PATH + offsetFileName);
        offsetFile = new File(BufferFileConfig.BUFFER_PATH + offsetFileName);
        this.offset.getWriteOffset().setWriteFileName(Const.EMPTY_STRING);
        this.offset.getWriteOffset().setWriteFileOffset(0);
        this.offset.getReadOffset().setReadFileName(Const.EMPTY_STRING);
@@ -99,7 +99,7 @@ public enum OffsetManager {
    private void nextFile() {
        String timeBucket = String.valueOf(TimeBucketUtils.INSTANCE.getSecondTimeBucket(System.currentTimeMillis()));
        String offsetFileName = OFFSET_FILE_PREFIX + "_" + timeBucket + "." + Const.FILE_SUFFIX;
        File newOffsetFile = new File(SegmentBufferConfig.BUFFER_PATH + offsetFileName);
        File newOffsetFile = new File(BufferFileConfig.BUFFER_PATH + offsetFileName);
        offsetFile.delete();
        offsetFile = newOffsetFile;
        this.flush();
+4 −5
Original line number Diff line number Diff line
@@ -44,14 +44,14 @@ public enum SegmentBufferManager {
        logger.info("segment buffer initialize");
        try {
            OffsetManager.INSTANCE.initialize();
            if (new File(SegmentBufferConfig.BUFFER_PATH).mkdirs()) {
            if (new File(BufferFileConfig.BUFFER_PATH).mkdirs()) {
                newDataFile();
            } else {
                String writeFileName = OffsetManager.INSTANCE.getWriteFileName();
                if (StringUtils.isNotEmpty(writeFileName)) {
                    File dataFile = new File(SegmentBufferConfig.BUFFER_PATH + writeFileName);
                    File dataFile = new File(BufferFileConfig.BUFFER_PATH + writeFileName);
                    if (dataFile.exists()) {
                        outputStream = new FileOutputStream(new File(SegmentBufferConfig.BUFFER_PATH + writeFileName), true);
                        outputStream = new FileOutputStream(new File(BufferFileConfig.BUFFER_PATH + writeFileName), true);
                    } else {
                        newDataFile();
                    }
@@ -83,7 +83,7 @@ public enum SegmentBufferManager {
        logger.debug("create new segment buffer file");
        String timeBucket = String.valueOf(TimeBucketUtils.INSTANCE.getSecondTimeBucket(System.currentTimeMillis()));
        String writeFileName = DATA_FILE_PREFIX + "_" + timeBucket + "." + Const.FILE_SUFFIX;
        File dataFile = new File(SegmentBufferConfig.BUFFER_PATH + writeFileName);
        File dataFile = new File(BufferFileConfig.BUFFER_PATH + writeFileName);
        dataFile.createNewFile();
        OffsetManager.INSTANCE.setWriteOffset(writeFileName, 0);
        try {
@@ -98,6 +98,5 @@ public enum SegmentBufferManager {
    }

    public synchronized void flush() {

    }
}
Loading