This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static ThreadLocal<MongoOgmDao> MongoOgmDaoLocal = | |
| new ThreadLocal<MongoOgmDao>() { | |
| @Override | |
| public MongoOgmDao initialValue() { | |
| log.debug("현 ThreadContext 에 저장소를 생성합니다..."); | |
| return new MongoOgmDao(); | |
| } | |
| }; | |
| @Scope("prototype") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public List<String> readAllLines(byte[] bytes, Charset charset) { | |
| if (bytes == null || bytes.length == 0) | |
| return new ArrayList<String>(); | |
| try (ByteArrayInputStream is = new ByteArrayInputStream(bytes); | |
| Reader in = new InputStreamReader(is, charset); | |
| BufferedReader br = new BufferedReader(in)) { | |
| List<String> lines = new ArrayList<String>(); | |
| while (true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try { | |
| fc = AsynchronousFileChannel.open(path, | |
| StandardOpenOption.READ, | |
| StandardOpenOption.DELETE_ON_CLOSE); | |
| ByteBuffer buffer = ByteBuffer.allocate((int) fc.size()); | |
| Future<Integer> result = fc.read(buffer, 0); | |
| while (!result.isDone()) { | |
| System.out.println("Do something else while reading..."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AsynchronousFileChannel fc = null; | |
| try { | |
| fc = AsynchronousFileChannel.open(path, | |
| StandardOpenOption.CREATE, | |
| StandardOpenOption.WRITE); | |
| ByteBuffer buffer = ByteBuffer.wrap(StringTool.replicate(TEST_TEXT, 1000).getBytes(UTF8)); | |
| Future<Integer> result = fc.write(buffer, 0); | |
| while (!result.isDone()) { | |
| System.out.println("Do something else while writing..."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void bufferedStreams() throws Exception { | |
| Path path = Paths.get("channel.txt"); | |
| try (BufferedWriter writer = Files.newBufferedWriter(path, UTF8, StandardOpenOption.CREATE, StandardOpenOption.APPEND)) { | |
| for (int i = 0; i < 100; i++) { | |
| writer.write(TEST_TEXT); | |
| } | |
| writer.flush(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NettyTransceiver calcClient = new NettyTransceiver(new InetSocketAddress(CALC_SERVER_PORT)); | |
| Calculator.Callback proxy = (Calculator.Callback) SpecificRequestor.getClient(Calculator.Callback.class, calcClient); | |
| System.out.println("Client built, get proxy"); | |
| proxy.add(2, 3, new Callback<Double>() { | |
| @Override | |
| public void handleResult(Double result) { | |
| System.out.println("Callback... add(2, 3)=" + result); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package example.avro.rpc; | |
| import lombok.extern.slf4j.Slf4j; | |
| import org.apache.avro.AvroRemoteException; | |
| import org.apache.avro.ipc.*; | |
| import org.apache.avro.ipc.specific.SpecificRequestor; | |
| import org.apache.avro.ipc.specific.SpecificResponder; | |
| import java.io.IOException; | |
| import java.net.InetSocketAddress; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @namespace("example.avro.search") | |
| protocol SearchService { | |
| record Entity { | |
| string rowId; | |
| string @order("ascending") createdAt; | |
| string text; | |
| map<string> attrs; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package example.avro.search; | |
| import com.google.common.collect.Lists; | |
| import com.google.common.collect.Maps; | |
| import lombok.extern.slf4j.Slf4j; | |
| import org.apache.avro.AvroRemoteException; | |
| import org.apache.avro.ipc.NettyServer; | |
| import org.apache.avro.ipc.NettyTransceiver; | |
| import org.apache.avro.ipc.Server; | |
| import org.apache.avro.ipc.specific.SpecificRequestor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <build> | |
| <plugins> | |
| <!-- Avro Plugin --> | |
| <plugin> | |
| <groupId>org.apache.avro</groupId> | |
| <artifactId>avro-maven-plugin</artifactId> | |
| <version>${avro.version}</version> | |
| <executions> | |
| <execution> | |
| <id>schemas</id> |