| 14 | import org.junit.Test; |
| 15 | |
| 16 | @SuppressWarnings("NewClassNamingConvention") |
| 17 | public final class Simulate { |
| 18 | static { |
| 19 | System.getProperties().putIfAbsent("log4j2.contextSelector", |
| 20 | "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); |
| 21 | } |
| 22 | |
| 23 | static final Logger logger = LogManager.getLogger(Simulate.class); |
| 24 | |
| 25 | public final static int AppCount = 10; |
| 26 | public final static int BatchTaskCount = 30000; |
| 27 | public final static int CacheCapacity = 1000; |
| 28 | public final static int AccessKeyBound = (int)(CacheCapacity * 1.2f); |
| 29 | private static Simulate instance; |
| 30 | |
| 31 | public static Simulate getInstance() { |
| 32 | return instance; |
| 33 | } |
| 34 | |
| 35 | private final ArrayList<App> Apps = new ArrayList<>(); |
| 36 | private long BatchNumber; |
| 37 | public boolean Infinite; // 当使用本目录的Main独立启动时,可以设置为true。 |
| 38 | |
| 39 | public Simulate() { |
| 40 | instance = this; |
| 41 | } |
| 42 | |
| 43 | public App randApp() { |
| 44 | return randApp(Apps.size()); |
| 45 | } |
| 46 | |
| 47 | public App randApp(int max) { |
| 48 | return Apps.get(Random.getInstance().nextInt(Math.min(max, Apps.size()))); |
| 49 | } |
| 50 | |
| 51 | @Before |
| 52 | public void Before() throws Exception { |
| 53 | After(); |
| 54 | for (int serverId = 10; serverId < AppCount + 10; serverId++) |
| 55 | Apps.add(new App(serverId)); |
| 56 | |
| 57 | for (var app : Apps) |
| 58 | app.Start(); |
| 59 | |
| 60 | var allTFlush = new ArrayList<Zeze.Transaction.TableX<Long, BValue>>(); |
| 61 | var allTable1 = new ArrayList<Zeze.Transaction.TableX<Long, BValue>>(); |
| 62 | for (var app : Apps) { |
| 63 | allTFlush.add(app.app.demo_Module1.getTflush()); |
| 64 | allTable1.add(app.app.demo_Module1.getTable1()); |
| 65 | } |
| 66 | for (var app : Apps) { |
| 67 | app.app.demo_Module1.getTflush().getSimulateTables = () -> allTFlush; |
| 68 | app.app.demo_Module1.getTable1().getSimulateTables = () -> allTable1; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | @After |
| 73 | public void After() throws Exception { |
nothing calls this directly
no test coverage detected