nizhikov commented on a change in pull request #8832: URL: https://github.com/apache/ignite/pull/8832#discussion_r594178708
########## File path: modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/DataModelGenerationApplication.java ########## @@ -0,0 +1,94 @@ +/* + * 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.ignite.internal.ducktest.tests; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication; + +/** + * + */ +public class DataModelGenerationApplication extends IgniteAwareApplication { + /** {@inheritDoc} */ + @Override protected void run(JsonNode jsonNode) throws Exception { + int cacheCnt = jsonNode.get("cacheCount").asInt(); + int entryCnt = jsonNode.get("entryCount").asInt(); + int entrySize = jsonNode.get("entrySize").asInt(); + + log.info("Creating " + cacheCnt + " caches each with " + entryCnt + " entries of " + entrySize + " bytes."); + + for (int i = 1; i <= cacheCnt; i++) + generateCache(i, entryCnt, entrySize); + + markSyncExecutionComplete(); + } + + /** + * @param cacheNo Cache number. + * @param entryCnt Entry count. + * @param entrySize Entry size. + */ + private void generateCache(int cacheNo, int entryCnt, int entrySize) { + IgniteCache<Integer, DataModel> cache = ignite.createCache("test-cache-" + cacheNo); + + try (IgniteDataStreamer<Integer, DataModel> stmr = ignite.dataStreamer(cache.getName())) { + for (int i = 0; i < entryCnt; i++) { + stmr.addData(i, newDataModel(entrySize)); + + if (i % 10_000 == 0) + log.info("Streamed " + i + " entries"); + } + } + } + + /** + * @param payloadSize Payload size. + */ + private DataModel newDataModel(int payloadSize) { + String randomStr = UUID.randomUUID().toString(); + + byte[] payload = new byte[payloadSize - randomStr.length()]; + + ThreadLocalRandom.current().nextBytes(payload); Review comment: I think we should go with the array that contains some random data not just nulls. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
