public NodeStateSolrServerConfigurationProvider(NodeState nodeState) { this.nodeState = nodeState; if (!nodeState.hasProperty(Properties.SERVER_TYPE)) { throw new IllegalArgumentException("missing property " + Properties.SERVER_TYPE + " in " + nodeState); } }
public Builder withProperty(String name) { checkNotNull(name, "name"); matchers.add(node -> node.hasProperty(name)); return this; }
static boolean hasProperty( NodeState base, Map<String, PropertyState> properties, String name) { if (properties.containsKey(name)) { return properties.get(name) != null; } else { return base.hasProperty(name); } }
static boolean hasProperty( NodeState base, Map<String, PropertyState> properties, String name) { if (properties.containsKey(name)) { return properties.get(name) != null; } else { return base.hasProperty(name); } }
public OakSolrNodeStateConfiguration(NodeState definition) { this.definition = definition; if (!definition.hasProperty("type") || !(SolrQueryIndex.TYPE.equals(definition.getProperty("type").getValue(Type.STRING)))) { throw new IllegalArgumentException("missing or wrong 'type' property in " + definition); } }
public static DocumentBundlor from(NodeState nodeState){ checkArgument(nodeState.hasProperty(PROP_PATTERN), "NodeState [%s] does not have required " + "property [%s]", nodeState, PROP_PATTERN); return DocumentBundlor.from(nodeState.getStrings(PROP_PATTERN)); }
private static <T> T getProperty(NodeState state, String name, Type<T> type) { if (state.hasProperty(name)) { return state.getProperty(name).getValue(type); } return null; }
private void init(AbstractAnalysisFactory o, NodeState state) { if (o instanceof ResourceLoaderAware) { try { ((ResourceLoaderAware) o).inform(new NodeStateResourceLoader(state, defaultLoader)); } catch (IOException e) { throw new IllegalArgumentException("Error occurred while initializing type " + o.getClass(), e); } } if (state.hasProperty(LuceneIndexConstants.ANL_LUCENE_MATCH_VERSION)){ o.setExplicitLuceneMatchVersion(true); } }
private boolean isPropertyNotNull(NodeState state, PropertyDefinition pd){ NodeState propertyNode = getPropertyNode(state, pd); if (!propertyNode.exists()){ return false; } return propertyNode.hasProperty(pd.nonRelativeName); }
private static <T> T getProperty(NodeState state, String name, Type<T> type) { if (state.hasProperty(name)) { return state.getProperty(name).getValue(type); } return null; }
public static Iterable<String> getStrings(NodeState node, String propertyName) { if (!node.hasProperty(propertyName)) { return null; } PropertyState s = node.getProperty(propertyName); if (s.isArray()) { return node.getStrings(propertyName); } return Collections.singleton(node.getString(propertyName)); }
public boolean isLocked(String asyncIndexerLane) { NodeState async = nodeStore.getRoot().getChildNode(":async"); String leaseName = lockName(asyncIndexerLane); return async.hasProperty(leaseName); }
public static Iterable<String> getStrings(NodeState node, String propertyName) { if (!node.hasProperty(propertyName)) { return null; } PropertyState s = node.getProperty(propertyName); if (s.isArray()) { return node.getStrings(propertyName); } return Collections.singleton(node.getString(propertyName)); }
static boolean hasAsyncIndexerRun(NodeState root, String indexPath, NodeState defnNodeState) { boolean hasAsyncNode = root.hasChildNode(ASYNC); String asyncLaneName = getAsyncLaneName(defnNodeState, indexPath, defnNodeState.getProperty(ASYNC_PROPERTY_NAME)); if (asyncLaneName != null) { return hasAsyncNode && root.getChildNode(ASYNC).hasProperty(asyncLaneName); } else { // useful only for tests - basically non-async index defs which don't rely on /:async // hence either readers are there (and this method doesn't come into play during open) // OR there is no cycle (where we return false correctly) return false; } }
@Override public Resolution deleteDeletedNode(NodeBuilder parent, String name, NodeState base) { called.set(true); assertTrue(base.hasProperty("p")); assertEquals("base", base.getProperty("p").getValue(STRING)); return Resolution.IGNORED; } };
@Override public Resolution changeDeletedNode(NodeBuilder parent, String name, NodeState ours, NodeState base) { called.set(true); assertTrue(ours.hasProperty("p")); assertTrue(base.hasProperty("p")); assertEquals("ours", ours.getProperty("p").getValue(STRING)); assertEquals("base", base.getProperty("p").getValue(STRING)); return Resolution.IGNORED; } };
@Override public Resolution deleteChangedNode(NodeBuilder parent, String name, NodeState theirs, NodeState base) { called.set(true); assertTrue(theirs.hasProperty("p")); assertTrue(base.hasProperty("p")); assertEquals("theirs", theirs.getProperty("p").getValue(STRING)); assertEquals("base", base.getProperty("p").getValue(STRING)); return Resolution.IGNORED; } };
private void verifyMetadata() { NodeState root = destination.getRoot(); assertTrue(root.hasProperty(PROP_REVISION)); assertTrue(root.hasProperty(PROP_LAST_REV)); RevisionVector.fromString(root.getString(PROP_REVISION)); Revision.fromString(root.getString(PROP_LAST_REV)); NodeState appsNode = destination.getRoot().getChildNode("apps"); assertTrue(appsNode.hasProperty(PROP_LAST_REV)); Revision.fromString(appsNode.getString(PROP_LAST_REV)); }
@Test public void rootPropertyIsSet() { assertThat("root[prop]", store.getRoot().hasProperty("prop"), equalTo(true)); assertThat("root[prop] = val", store.getRoot().getProperty("prop").getValue(Type.STRING), equalTo("val")); }
@Test public void builderBasedOnRootStoreChildNode() throws Exception { NodeBuilder builder = store.getRoot().builder(); NodeBuilder appsBuilder = builder.getChildNode("apps"); appsBuilder.removeProperty("prop"); appsBuilder.setChildNode("child1"); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); assertFalse("Node apps must have no properties (composite store)", store.getRoot().getChildNode("apps").hasProperty("prop")); assertFalse("Node apps must have no properties (root store)", globalStore.getRoot().getChildNode("apps").hasProperty("prop")); assertTrue("Node /apps/child1 must exist (composite store)", store.getRoot().getChildNode("apps").hasChildNode("child1")); assertTrue("Node /apps/child1 must exist (root store)", globalStore.getRoot().getChildNode("apps").hasChildNode("child1")); }