store.getStatsCollector().failedMerge(numRetries, time, suspendMillis, exclusive); String msg = ex.getMessage() + " (retries " + numRetries + ", " + time + " ms)"; throw new CommitFailedException(ex.getSource(), ex.getType(), ex.getCode(), msg, ex.getCause());
store.getStatsCollector().failedMerge(numRetries, time, suspended, exclusive); String msg = ex.getMessage() + " (retries " + numRetries + ", " + time + " ms)"; throw new CommitFailedException(ex.getSource(), ex.getType(), ex.getCode(), msg, ex.getCause());
private static void assertCyclicMembershipError(Exception e) { Throwable th = e.getCause(); if (th != null) { assertTrue(th instanceof CommitFailedException); CommitFailedException ce = (CommitFailedException) th; assertEquals(CommitFailedException.CONSTRAINT, ce.getType()); assertEquals(31, ce.getCode()); } }
@Test public void type() { ConflictException e = new ConflictException("conflict"); CommitFailedException cfe = e.asCommitFailedException(); assertEquals(CommitFailedException.MERGE, cfe.getType()); }
@Test public void singleUniqueProperty() throws Exception{ defnb.indexRule("nt:base").property("foo").unique(); updateRootState("/a", "foo", "bar"); updateRootState("/b", "foo", "bar"); PropertyUpdateCallback callback = newCallback(); callback.propertyUpdated("/a", "foo", pd("foo"), null, createProperty("foo", "bar")); callback.propertyUpdated("/b", "foo", pd("foo"), null, createProperty("foo", "bar")); try { callback.done(); fail(); } catch (CommitFailedException e) { assertEquals(CONSTRAINT, e.getType()); assertEquals(30, e.getCode()); assertThat(e.getMessage(), containsString(indexPath)); assertThat(e.getMessage(), containsString("/a")); assertThat(e.getMessage(), containsString("/b")); assertThat(e.getMessage(), containsString("foo")); } }
@Test public void uniquePaths() throws Exception{ defnb.async("async", "nrt"); defnb.indexRule("nt:base").property("foo").propertyIndex().unique(); addIndex(indexPath, defnb); root.commit(); createPath("/a").setProperty("foo", "bar"); root.commit(); assertQuery("select * from [nt:base] where [foo] = 'bar'", singletonList("/a")); runAsyncIndex(); createPath("/b").setProperty("foo", "bar2"); root.commit(); runAsyncIndex(); createPath("/c").setProperty("foo", "bar3"); root.commit(); assertQuery("select * from [nt:base] where [foo] = 'bar'", singletonList("/a")); assertQuery("select * from [nt:base] where [foo] = 'bar2'", singletonList("/b")); assertQuery("select * from [nt:base] where [foo] = 'bar3'", singletonList("/c")); createPath("/d").setProperty("foo", "bar"); try { root.commit(); fail(); } catch (CommitFailedException e) { assertEquals(CONSTRAINT, e.getType()); } }
@Test public void uniquePropertyCommit() throws Exception{ defnb.async("async", "nrt"); defnb.indexRule("nt:base").property("foo").propertyIndex().unique(); addIndex(indexPath, defnb); root.commit(); createPath("/a").setProperty("foo", "bar"); root.commit(); createPath("/b").setProperty("foo", "bar"); try { root.commit(); fail(); } catch (CommitFailedException e) { assertEquals(CONSTRAINT, e.getType()); } }
fail(); } catch (CommitFailedException e){ assertEquals(CONSTRAINT,e.getType());
@Test public void uniquePropertyCommit_Async() throws Exception{ defnb.async("async", "nrt"); defnb.indexRule("nt:base").property("foo").propertyIndex().unique(); addIndex(indexPath, defnb); root.commit(); createPath("/a").setProperty("foo", "bar"); root.commit(); runAsyncIndex(); //Remove the :property-index node to simulate bucket change //This time commit would trigger a lucene query NodeBuilder builder = nodeStore.getRoot().builder(); String propIdxStorePath = concat(indexPath, HybridPropertyIndexUtil.PROPERTY_INDEX); NodeBuilder propIndex = TestUtil.child(builder, propIdxStorePath); propIndex.remove(); nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); root.refresh(); createPath("/b").setProperty("foo", "bar"); try { root.commit(); fail(); } catch (CommitFailedException e) { assertEquals(CONSTRAINT, e.getType()); } }