-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #475 from refinedmods/release/2.0.0-milestone.3.3
Release v2.0.0-milestone.3.3
- Loading branch information
Showing
382 changed files
with
7,906 additions
and
4,299 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
20 changes: 20 additions & 0 deletions
20
...src/main/java/com/refinedmods/refinedstorage2/api/grid/operations/NoopGridOperations.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 @@ | ||
package com.refinedmods.refinedstorage2.api.grid.operations; | ||
|
||
import com.refinedmods.refinedstorage2.api.storage.ExtractableStorage; | ||
import com.refinedmods.refinedstorage2.api.storage.InsertableStorage; | ||
|
||
public class NoopGridOperations<T> implements GridOperations<T> { | ||
@Override | ||
public boolean extract(final T resource, | ||
final GridExtractMode extractMode, | ||
final InsertableStorage<T> destination) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean insert(final T resource, | ||
final GridInsertMode insertMode, | ||
final ExtractableStorage<T> source) { | ||
return false; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ain/java/com/refinedmods/refinedstorage2/api/grid/watcher/GridStorageChannelProvider.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,18 @@ | ||
package com.refinedmods.refinedstorage2.api.grid.watcher; | ||
|
||
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannel; | ||
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannelType; | ||
|
||
import java.util.Set; | ||
|
||
import org.apiguardian.api.API; | ||
|
||
/** | ||
* Provides the {@link GridWatcherManagerImpl} with {@link StorageChannel}s. | ||
*/ | ||
@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.3") | ||
public interface GridStorageChannelProvider { | ||
Set<StorageChannelType<?>> getStorageChannelTypes(); | ||
|
||
<T> StorageChannel<T> getStorageChannel(StorageChannelType<T> type); | ||
} |
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
26 changes: 26 additions & 0 deletions
26
...pi/src/main/java/com/refinedmods/refinedstorage2/api/grid/watcher/GridWatcherManager.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,26 @@ | ||
package com.refinedmods.refinedstorage2.api.grid.watcher; | ||
|
||
import com.refinedmods.refinedstorage2.api.storage.Actor; | ||
|
||
import org.apiguardian.api.API; | ||
|
||
/** | ||
* This manager helps with attaching and detaching listeners to | ||
* {@link com.refinedmods.refinedstorage2.api.storage.channel.StorageChannel}s. | ||
*/ | ||
@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.3") | ||
public interface GridWatcherManager { | ||
void addWatcher( | ||
GridWatcher watcher, | ||
Class<? extends Actor> actorType, | ||
GridStorageChannelProvider storageChannelProvider | ||
); | ||
|
||
void attachAll(GridStorageChannelProvider storageChannelProvider); | ||
|
||
void removeWatcher(GridWatcher watcher, GridStorageChannelProvider storageChannelProvider); | ||
|
||
void detachAll(GridStorageChannelProvider storageChannelProvider); | ||
|
||
void activeChanged(boolean active); | ||
} |
110 changes: 110 additions & 0 deletions
110
...rc/main/java/com/refinedmods/refinedstorage2/api/grid/watcher/GridWatcherManagerImpl.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,110 @@ | ||
package com.refinedmods.refinedstorage2.api.grid.watcher; | ||
|
||
import com.refinedmods.refinedstorage2.api.storage.Actor; | ||
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannelType; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.apiguardian.api.API; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.3") | ||
public class GridWatcherManagerImpl implements GridWatcherManager { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(GridWatcherManagerImpl.class); | ||
|
||
private final Map<GridWatcher, GridWatcherRegistration> watchers = new HashMap<>(); | ||
|
||
@Override | ||
public void addWatcher( | ||
final GridWatcher watcher, | ||
final Class<? extends Actor> actorType, | ||
final GridStorageChannelProvider storageChannelProvider | ||
) { | ||
if (watchers.containsKey(watcher)) { | ||
throw new IllegalArgumentException("Watcher is already registered"); | ||
} | ||
final GridWatcherRegistration registration = new GridWatcherRegistration(watcher, actorType); | ||
attachAll(registration, storageChannelProvider, false); | ||
watchers.put(watcher, registration); | ||
LOGGER.info("Added watcher {}, new count is {}", watcher, watchers.size()); | ||
} | ||
|
||
@Override | ||
public void attachAll(final GridStorageChannelProvider storageChannelProvider) { | ||
// If we get here we are affected by a network split or network merge. | ||
// At this point, all the storages that are affected by the split or merge have not yet been processed | ||
// as the grid has the highest priority. | ||
watchers.forEach((watcher, registration) -> { | ||
// Invalidate all watcher data, the resources that were synced earlier are no longer valid because we have | ||
// a brand-new network. | ||
watcher.invalidate(); | ||
// Re-attach the watcher to the new network, and send all the resources from the new network. | ||
// Resources from the old network are not part of the new network yet, as mentioned above, | ||
// but those will be synced when the storages are re-added. | ||
attachAll(registration, storageChannelProvider, true); | ||
}); | ||
} | ||
|
||
private void attachAll(final GridWatcherRegistration registration, | ||
final GridStorageChannelProvider storageChannelProvider, | ||
final boolean replay) { | ||
storageChannelProvider.getStorageChannelTypes().forEach(storageChannelType -> attach( | ||
registration, | ||
storageChannelType, | ||
storageChannelProvider, | ||
replay | ||
)); | ||
} | ||
|
||
private <T> void attach( | ||
final GridWatcherRegistration registration, | ||
final StorageChannelType<T> storageChannelType, | ||
final GridStorageChannelProvider storageChannelProvider, | ||
final boolean replay | ||
) { | ||
LOGGER.info("Attaching {} to {}", registration, storageChannelType); | ||
registration.attach(storageChannelProvider.getStorageChannel(storageChannelType), storageChannelType, replay); | ||
} | ||
|
||
@Override | ||
public void removeWatcher(final GridWatcher watcher, final GridStorageChannelProvider storageChannelProvider) { | ||
final GridWatcherRegistration registration = watchers.get(watcher); | ||
if (registration == null) { | ||
throw new IllegalArgumentException("Watcher is not registered"); | ||
} | ||
detachAll(registration, storageChannelProvider); | ||
watchers.remove(watcher); | ||
LOGGER.info("Removed watcher {}, remaining {}", watcher, watchers.size()); | ||
} | ||
|
||
@Override | ||
public void detachAll(final GridStorageChannelProvider storageChannelProvider) { | ||
LOGGER.info("Detaching {} watchers", watchers.size()); | ||
watchers.values().forEach(w -> detachAll(w, storageChannelProvider)); | ||
} | ||
|
||
private void detachAll(final GridWatcherRegistration registration, | ||
final GridStorageChannelProvider storageChannelProvider) { | ||
storageChannelProvider.getStorageChannelTypes().forEach(storageChannelType -> detach( | ||
registration, | ||
storageChannelType, | ||
storageChannelProvider | ||
)); | ||
} | ||
|
||
private <T> void detach( | ||
final GridWatcherRegistration registration, | ||
final StorageChannelType<T> storageChannelType, | ||
final GridStorageChannelProvider storageChannelProvider | ||
) { | ||
LOGGER.info("Detaching {} from {}", registration, storageChannelType); | ||
registration.detach(storageChannelProvider.getStorageChannel(storageChannelType), storageChannelType); | ||
} | ||
|
||
@Override | ||
public void activeChanged(final boolean active) { | ||
watchers.keySet().forEach(watcher -> watcher.onActiveChanged(active)); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...efinedstorage2/api/grid/package-info.java → ...orage2/api/grid/watcher/package-info.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
Oops, something went wrong.