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
// Example of the executor service | |
class UserRepository implements Closeable { | |
private FileStore fileStore; | |
private ConcurrentHashMap<UUID, User> cache = new ConcurrentHashMap<>(); | |
private ReadWriteLock lock = new ReentrantReadWriteLock(); | |
private ExecutorService executors = Executors.newFixedThreadPool(2); | |
UserRepository(FileStore fnileStore) { | |
this.fileStore = fileStore; |
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
//Helper Class for read and write operations for a file. | |
class FileStore { | |
private File storeFolder; | |
// Locks is used so that only one thread can update the file at a | |
// time. | |
private ReadWriteLock lock = new ReentrantReadWriteLock(); |
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
DeleteListValue deleteList = DeleteListValue.builder().uid(uid) | |
.hobbies("Drawing").build(); | |
if (daoOperation.deleteNode(deleteList)) { | |
]System.out.println("Update Transaction completed"); | |
]} |
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
@Builder | |
@Getter | |
public final class DeleteListValue { | |
private final String uid; | |
private final String hobbies; | |
} | |
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
if (daoOperation.deleteNode(Address.builder().uid(addressDeleteUid).build())) { | |
System.out.println("Delete Transaction for address completed"); | |
} |
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
public <T> boolean deleteNode(final T element) { | |
try (Transaction txn = dgraphClient.newTransaction()) { | |
try { | |
final DgraphProto.Mutation mutation = getDeleteMutation(element); | |
txn.mutate(mutation); | |
txn.commit(); | |
return true; |
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
DeleteAddressPojo deletePerson = DeleteAddressPojo.builder() | |
.address(DeleteAddress.builder().uid(addressUid).build()).uid(uid).build(); | |
if (daoOperation.deleteNode(deletePerson)) { | |
System.out.println("Delete Transaction completed"); | |
} | |
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
@Builder | |
@Getter | |
@AllArgsConstructor | |
public final class DeleteAddressPojo { | |
private final String uid; | |
private final DeleteAddress address; | |
} | |
@Builder |
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
<configuration> | |
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> | |
<file>testFile.log</file> | |
<!-- encoders are assigned the type | |
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
<encoder> | |
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern> | |
</encoder> | |
</appender> |
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
<configuration> | |
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
<!-- encoders are assigned the type | |
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
<encoder> | |
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern> | |
</encoder> | |
</appender> |
NewerOlder