/** * @throws Exception In case of an error. */ @Test public void test5PartitionsNotIdealDistributionSuppressedLoggingOnClientNode() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "0.0"); nodes = 4; parts = 5; backups = 3; String testsLog = runAndGetExchangeLog(true); assertFalse(testsLog.contains(LOG_MESSAGE_PREFIX)); }
/** * @throws Exception In case of an error. */ @Test public void test5PartitionsNotIdealDistributionIsLogged() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "50.0"); nodes = 4; parts = 5; backups = 3; String testsLog = runAndGetExchangeLog(false); assertTrue(testsLog.contains(LOG_MESSAGE_PREFIX)); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); System.clearProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD); stopAllGrids(); }
/** * Starts a specified number of Ignite nodes and log partition node exchange during a last node's startup. * * @param testClientNode Whether it is necessary to get exchange log from the client node. * @return Log of latest partition map exchange. * @throws Exception In case of an error. */ private String runAndGetExchangeLog(boolean testClientNode) throws Exception { assert nodes > 1; IgniteEx ignite = (IgniteEx)startGrids(nodes - 1); awaitPartitionMapExchange(); GridCacheProcessor proc = ignite.context().cache(); GridCacheContext cctx = proc.context().cacheContext(CU.cacheId(DEFAULT_CACHE_NAME)); final GridStringLogger log = new GridStringLogger(false, this.log); GridAffinityAssignmentCache aff = GridTestUtils.getFieldValue(cctx.affinity(), "aff"); GridTestUtils.setFieldValue(aff, "log", log); if (testClientNode) { IgniteConfiguration cfg = getConfiguration("client"); cfg.setClientMode(true); startGrid(cfg); } else startGrid(nodes); awaitPartitionMapExchange(); return log.toString(); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(CacheMode.PARTITIONED); cacheCfg.setBackups(backups); cacheCfg.setAffinity(new EvenDistributionAffinityFunction(parts)); cfg.setCacheConfiguration(cacheCfg); return cfg; }
/** * @throws Exception In case of an error. */ @Test public void test120PartitionsIdeadDistributionIsNotLogged() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "0.0"); nodes = 3; parts = 120; backups = 2; String testsLog = runAndGetExchangeLog(false); assertFalse(testsLog.contains(LOG_MESSAGE_PREFIX)); }
/** * @throws Exception In case of an error. */ @Test public void test2PartitionsIdealDistributionIsNotLogged() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "0"); nodes = 2; parts = 2; backups = 1; String testsLog = runAndGetExchangeLog(false); assertFalse(testsLog.contains(LOG_MESSAGE_PREFIX)); }
/** * @throws Exception In case of an error. */ @Test public void test7PartitionsNotIdealDistributionSuppressedLogging() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "50.0"); nodes = 3; parts = 7; backups = 0; String testsLog = runAndGetExchangeLog(false); assertFalse(testsLog.contains(LOG_MESSAGE_PREFIX)); }
/** * @throws Exception In case of an error. */ @Test public void test5PartitionsNotIdealDistributionSuppressedLogging() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "65"); nodes = 4; parts = 5; backups = 3; String testsLog = runAndGetExchangeLog(false); assertFalse(testsLog.contains(LOG_MESSAGE_PREFIX)); }