Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions inlong-common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.inlong</groupId>
<artifactId>inlong</artifactId>
<version>0.9.0-incubating-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<groupId>org.apache.inlong</groupId>
<artifactId>inlong-common</artifactId>
<name>Apache InLong - Common</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.1.0</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>11.0.2</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<!-- bind the maven-assembly-plugin to the package phase this will create
a jar file without the storm dependencies suitable for deployment to a cluster. -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>

</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.theoryinpractise
</groupId>
<artifactId>
clojure-maven-plugin
</artifactId>
<versionRange>
[1.3.8,)
</versionRange>
<goals>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.inlong.commons.msg;

public interface AttributeConstants {

String SEPARATOR = "&";
String KEY_VALUE_SEPARATOR = "=";

/**
* business id
* unique string id for each business or product
*/
String BUSINESS_ID = "bid";

/**
* interface id
* unique string id for each interface of business
* An interface stand for a kind of data
*/
String INTERFACE_ID = "tid";

/**
* iname is like a tid but used in file protocol(m=xxx)
*/
String INAME = "iname";

/**
* data time
*/
String DATA_TIME = "dt";

String TIME_STAMP = "t";

/* compress type */
String COMPRESS_TYPE = "cp";

/* count value for how many records a message body contains */
String MESSAGE_COUNT = "cnt";

/* message type */
String MESSAGE_TYPE = "mt";

/* sort type */
String METHOD = "m";

/* global unique id for a message*/
String SEQUENCE_ID = "sid";

String UNIQ_ID = "uniq";

/* from where */
String FROM = "f";

String RCV_TIME = "rt";

String NODE_IP = "NodeIP";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.inlong.commons.msg;


import java.io.ByteArrayInputStream;
import java.io.DataInputStream;

/**
* A reusable {@link DataInput} implementation that reads from an in-memory
* buffer.
*
* <p>This saves memory over creating a new DataInputStream and
* ByteArrayInputStream each time data is read.
*
* <p>Typical usage is something like the following:<pre>
*
* DataInputBuffer buffer = new DataInputBuffer();
* while (... loop condition ...) {
* byte[] data = ... get data ...;
* int dataLength = ... get data length ...;
* buffer.reset(data, dataLength);
* ... read buffer using DataInput methods ...
* }
* </pre>
*/
public class DataInputBuffer extends DataInputStream {
private static class Buffer extends ByteArrayInputStream {
public Buffer() {
super(new byte[]{
//
});
}

public void reset(byte[] input, int start, int length) {
this.buf = input;
this.count = start + length;
this.mark = start;
this.pos = start;
}

public byte[] getData() {
return buf;
}

public int getPosition() {
return pos;
}

public int getLength() {
return count;
}
}

private Buffer buffer;

/**
* Constructs a new empty buffer.
*/
public DataInputBuffer() {
this(new Buffer());
}

private DataInputBuffer(Buffer buffer) {
super(buffer);
this.buffer = buffer;
}

/**
* Resets the data that the buffer reads.
*/
public void reset(byte[] input, int length) {
buffer.reset(input, 0, length);
}

/**
* Resets the data that the buffer reads.
*/
public void reset(byte[] input, int start, int length) {
buffer.reset(input, start, length);
}

public byte[] getData() {
return buffer.getData();
}

/**
* Returns the current position in the input.
*/
public int getPosition() {
return buffer.getPosition();
}

/**
* Returns the length of the input.
*/
public int getLength() {
return buffer.getLength();
}

}
Loading