-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to configure wait options for new Neo4j databases (#31129)
* Allow users to configure wait options for new Neo4j databases Since v5 of Neo4j, databases are created in an asynchronous manner. Before this commit, `Neo4jResourceManager` did not allow users to specify whether to wait or not for the database creation (via the corresponding Cypher syntax element). This commit fixes that, while keeping the behavior the same as before, by default (which is to not wait). * Format * Fold back intermediate classes * Format again
- Loading branch information
Showing
5 changed files
with
138 additions
and
8 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
it/neo4j/src/main/java/org/apache/beam/it/neo4j/DatabaseWaitOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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.beam.it.neo4j; | ||
|
||
public interface DatabaseWaitOption {} |
68 changes: 68 additions & 0 deletions
68
it/neo4j/src/main/java/org/apache/beam/it/neo4j/DatabaseWaitOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* 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.beam.it.neo4j; | ||
|
||
public class DatabaseWaitOptions { | ||
|
||
public static DatabaseWaitOption waitDatabase() { | ||
return DatabaseWait.WAIT; | ||
} | ||
|
||
public static DatabaseWaitOption waitDatabase(int seconds) { | ||
return new DatabaseWaitInSeconds(seconds); | ||
} | ||
|
||
public static DatabaseWaitOption noWaitDatabase() { | ||
return DatabaseNoWait.NO_WAIT; | ||
} | ||
|
||
static String asCypher(DatabaseWaitOption option) { | ||
if (option == null || option == DatabaseNoWait.NO_WAIT) { | ||
return "NOWAIT"; | ||
} | ||
if (option == DatabaseWait.WAIT) { | ||
return "WAIT"; | ||
} | ||
if (option instanceof DatabaseWaitInSeconds) { | ||
DatabaseWaitInSeconds wait = (DatabaseWaitInSeconds) option; | ||
return String.format("WAIT %s SECONDS", wait.getSeconds()); | ||
} | ||
throw new Neo4jResourceManagerException( | ||
String.format("Unsupported wait option type %s", option.getClass())); | ||
} | ||
|
||
private enum DatabaseNoWait implements DatabaseWaitOption { | ||
NO_WAIT; | ||
} | ||
|
||
private enum DatabaseWait implements DatabaseWaitOption { | ||
WAIT; | ||
} | ||
|
||
private static class DatabaseWaitInSeconds implements DatabaseWaitOption { | ||
private final int seconds; | ||
|
||
public DatabaseWaitInSeconds(int seconds) { | ||
this.seconds = seconds; | ||
} | ||
|
||
public int getSeconds() { | ||
return seconds; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters