Refactor entry writing to replication buffer, #62

This commit is contained in:
leventov
2015-12-17 13:46:26 +03:00
parent 12c8503434
commit e78e070558
6 changed files with 179 additions and 53 deletions
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2015 higherfrequencytrading.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetSocketAddress;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import static net.openhft.chronicle.map.Issue62ChronicleServer.MAP_FILE_B;
import static net.openhft.chronicle.map.Issue62ChronicleServer.prepare;
public class Issue62ChronicleClient {
private final static Logger LOGGER = LoggerFactory.getLogger(Issue62ChronicleClient.class);
public static void main(String[] args) throws Exception {
prepare(MAP_FILE_B);
ChronicleMapBuilder<String, Long> cityPostalCodesMapBuilder =
ChronicleMapBuilder.of(String.class, Long.class)
//.averageKeySize(100)
.averageKey(Issue62ChronicleServer.STR)
.replication((byte) 2, TcpTransportAndNetworkConfig
.of(8077, new InetSocketAddress("localhost", 8076))
.heartBeatInterval(1, TimeUnit.SECONDS))
.entries(50_000);
try (ChronicleMap<String, Long> map =
cityPostalCodesMapBuilder.createPersistedTo(MAP_FILE_B)) {
LOGGER.info("Starting");
Thread.sleep(3000);
for (Entry<String, Long> entry : map.entrySet()) {
LOGGER.info("{} : {}", entry.getKey(), entry.getValue());
}
}
}
}