Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release vv2.0.0-milestone.3.2 #451

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
83b5155
Merge pull request #440 from refinedmods/main
raoulvdberge Oct 30, 2023
36e1ac0
fix: cleanup some storage monitor code
raoulvdberge Oct 31, 2023
8728857
refactor: split up configuration read/writes from unique read/writes
raoulvdberge Oct 31, 2023
8330c0d
feat: configuration card
raoulvdberge Oct 31, 2023
10d6e82
Merge pull request #441 from refinedmods/feature/GH-204/config-card
raoulvdberge Oct 31, 2023
07e5445
feat: network receiver
raoulvdberge Oct 31, 2023
456a3cf
refactor: class hierarchy of network node containers
raoulvdberge Oct 31, 2023
ed5652d
Merge pull request #442 from refinedmods/feature/GH-96/network-receiver
raoulvdberge Oct 31, 2023
a9edf42
refactor: partition by feature
raoulvdberge Oct 31, 2023
d109b09
Merge pull request #444 from refinedmods/refactor/GH-443/partitioning
raoulvdberge Oct 31, 2023
dc0224f
refactor: make more classes package-private
raoulvdberge Nov 1, 2023
60c0863
feat: network card
raoulvdberge Nov 1, 2023
a8ef002
Merge pull request #445 from refinedmods/feat/GH-95/network-card
raoulvdberge Nov 1, 2023
17a5609
fix: inactive wireless transmitter and network receiver models being …
raoulvdberge Nov 3, 2023
2edb8e8
refactor: add network package structure under support
raoulvdberge Nov 3, 2023
68de9f7
refactor: make more methods package private
raoulvdberge Nov 3, 2023
e3c4298
refactor: move fluid amount formatting to FluidResourceRendering
raoulvdberge Nov 3, 2023
82658d8
refactor: move ClientProxy to forge layer
raoulvdberge Nov 3, 2023
d0ccbba
refactor: move FabricStorageUtil to storage package
raoulvdberge Nov 3, 2023
d325cae
refactor: more package private classes in platform modules
raoulvdberge Nov 3, 2023
adde7b8
Merge pull request #447 from refinedmods/fix/GH-446/emissive-fix
raoulvdberge Nov 3, 2023
203f35b
feat: network node containers can now determine their outgoing connec…
raoulvdberge Nov 3, 2023
cefe319
Merge pull request #448 from refinedmods/feat/GH-97/node-connections
raoulvdberge Nov 3, 2023
2623f2c
refactor: provide GraphNetworkComponent as API and allow specifying a…
raoulvdberge Nov 3, 2023
7fa22d0
fix: update network node activeness independently from the block stat…
raoulvdberge Nov 3, 2023
c6a0585
Merge pull request #449 from refinedmods/feat/GH-97/network-transmitt…
raoulvdberge Nov 3, 2023
cb071db
feat: network transmitter
raoulvdberge Nov 1, 2023
1c2323d
fix: network updating twice when activeness changes
raoulvdberge Nov 3, 2023
5d55840
fix: cable blocks not updating connections properly when using wrench
raoulvdberge Nov 3, 2023
4313ca5
refactor: move network card inventory to its own class
raoulvdberge Nov 3, 2023
f7de1e9
fix: some sonar issues
raoulvdberge Nov 3, 2023
c782f9e
Merge pull request #450 from refinedmods/feat/GH-97/network-transmitter
raoulvdberge Nov 3, 2023
af2f654
chore: prepare release vv2.0.0-milestone.3.2
raoulvdberge Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [v2.0.0-milestone.3.2] - 2023-11-03

### Added

- Configuration Card. It copies device configurations and can transfer upgrades.
- Network Receiver
- Network Card
- Network Transmitter

### Changed

- The Network Transmitter now goes into an "errored" state if there is no connection (anymore) with the Network Receiver (due to chunk unloading for example).
- The Network Transmitter will actively try to reconnect with the Network Receiver if connection is lost.

### Fixed

- Inactive Wireless Transmitter model being emissive.
- Unneeded network graph updating after placing a network device.
- Cable blocks not updating connections properly when using wrench.

## [2.0.0-milestone.3.1] - 2023-10-30

### Added
Expand Down Expand Up @@ -477,7 +497,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- The Grid can now use smooth scrolling.
- The Grid now has syntax highlighting for the search query.

[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.1...HEAD
[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/vv2.0.0-milestone.3.2...HEAD

[v2.0.0-milestone.3.2]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.1...vv2.0.0-milestone.3.2

[2.0.0-milestone.3.1]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.0...v2.0.0-milestone.3.1

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.refinedmods.refinedstorage2.api.network.component;

import com.refinedmods.refinedstorage2.api.network.node.container.NetworkNodeContainer;

import java.util.Set;
import javax.annotation.Nullable;

import org.apiguardian.api.API;

/**
* Responsible for managing the connected network nodes in a network.
*/
@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.2")
public interface GraphNetworkComponent extends NetworkComponent {
/**
* @return all the containers currently present in this graph
*/
Set<NetworkNodeContainer> getContainers();

/**
* Retrieves containers by container type.
* It can be queried by exact class type or by interface type.
*
* @param clazz the container class type
* @param <T> the container class type
* @return the containers matching the type
*/
<T> Set<T> getContainers(Class<T> clazz);

/**
* Retrieves a container by key, defined in {@link NetworkNodeContainer#createKey()}.
*
* @param key the key
* @return the container, or null if not found
*/
@Nullable
NetworkNodeContainer getContainer(Object key);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@

import com.refinedmods.refinedstorage2.api.network.node.NetworkNode;

import javax.annotation.Nullable;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0")
@FunctionalInterface
public interface NetworkNodeContainer {
NetworkNode getNode();

/**
* If this container needs to be indexed by the network graph, so it can be queried quickly (by key),
* you can return a key here.
* The key must be kept stable, and must stay the same for the lifetime of the container.
* If it changes after adding it into the graph, the container would not be removed from the key index when the
* container is removed!
* The container can be queried by
* {@link com.refinedmods.refinedstorage2.api.network.component.GraphNetworkComponent#getContainer(Object)}.
*
* @return the key, or null if indexing is not required
*/
@Nullable
default Object createKey() {
return null;
}

/**
* The container priority determines the order in which the remainder containers as the result of a network split
* are re-initialized with a new network.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import com.refinedmods.refinedstorage2.api.core.component.ComponentMapFactory;
import com.refinedmods.refinedstorage2.api.network.Network;
import com.refinedmods.refinedstorage2.api.network.component.EnergyNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.NetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.StorageNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.impl.component.EnergyNetworkComponentImpl;
import com.refinedmods.refinedstorage2.api.network.impl.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.impl.component.GraphNetworkComponentImpl;
import com.refinedmods.refinedstorage2.api.network.impl.component.StorageNetworkComponentImpl;
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannelImpl;
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannelType;
Expand All @@ -26,7 +27,7 @@ public final class NetworkTestFixtures {
);
NETWORK_COMPONENT_MAP_FACTORY.addFactory(
GraphNetworkComponent.class,
GraphNetworkComponent::new
GraphNetworkComponentImpl::new
);
NETWORK_COMPONENT_MAP_FACTORY.addFactory(
StorageNetworkComponent.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.refinedmods.refinedstorage2.api.network.Network;
import com.refinedmods.refinedstorage2.api.network.component.EnergyNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.StorageNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.impl.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.impl.node.SimpleNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.multistorage.MultiStorageNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.storage.StorageNetworkNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.refinedmods.refinedstorage2.api.network.Connections;
import com.refinedmods.refinedstorage2.api.network.Network;
import com.refinedmods.refinedstorage2.api.network.NetworkBuilder;
import com.refinedmods.refinedstorage2.api.network.impl.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.node.NetworkNode;
import com.refinedmods.refinedstorage2.api.network.node.container.NetworkNodeContainer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
package com.refinedmods.refinedstorage2.api.network.impl.component;

import com.refinedmods.refinedstorage2.api.network.Network;
import com.refinedmods.refinedstorage2.api.network.component.NetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.node.container.NetworkNodeContainer;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GraphNetworkComponent implements NetworkComponent {
private static final Logger LOGGER = LoggerFactory.getLogger(GraphNetworkComponent.class);
public class GraphNetworkComponentImpl implements GraphNetworkComponent {
private static final Logger LOGGER = LoggerFactory.getLogger(GraphNetworkComponentImpl.class);

private final Network network;
private final Set<NetworkNodeContainer> containers = new HashSet<>();
private final Map<Class<?>, Set<NetworkNodeContainer>> containerIndex = new HashMap<>();
private final Map<Class<?>, Set<NetworkNodeContainer>> byClassIndex = new HashMap<>();
private final Map<Object, NetworkNodeContainer> byKeyIndex = new HashMap<>();

public GraphNetworkComponent(final Network network) {
public GraphNetworkComponentImpl(final Network network) {
this.network = network;
}

@Override
public Set<NetworkNodeContainer> getContainers() {
return Collections.unmodifiableSet(containers);
}

@Override
@SuppressWarnings("unchecked")
public <T> Set<T> getContainers(final Class<T> clazz) {
return (Set<T>) Collections.unmodifiableSet(containerIndex.getOrDefault(clazz, Collections.emptySet()));
return (Set<T>) Collections.unmodifiableSet(byClassIndex.getOrDefault(clazz, Collections.emptySet()));
}

@Override
@Nullable
public NetworkNodeContainer getContainer(final Object key) {
return byKeyIndex.get(key);
}

@Override
Expand All @@ -44,10 +54,14 @@ public void onContainerAdded(final NetworkNodeContainer container) {
public void onContainerRemoved(final NetworkNodeContainer container) {
LOGGER.debug("Container {} removed from network {}", container, network.hashCode());
containers.remove(container);
deleteFromIndex(container);
removeFromIndex(container);
}

private void addToIndex(final NetworkNodeContainer container) {
final Object key = container.createKey();
if (key != null) {
byKeyIndex.put(key, container);
}
final Class<? extends NetworkNodeContainer> clazz = container.getClass();
addToIndex(clazz, container);
for (final Class<?> iface : clazz.getInterfaces()) {
Expand All @@ -56,23 +70,27 @@ private void addToIndex(final NetworkNodeContainer container) {
}

private void addToIndex(final Class<?> indexKey, final NetworkNodeContainer container) {
containerIndex.computeIfAbsent(indexKey, k -> new HashSet<>()).add(container);
byClassIndex.computeIfAbsent(indexKey, k -> new HashSet<>()).add(container);
}

private void deleteFromIndex(final NetworkNodeContainer container) {
private void removeFromIndex(final NetworkNodeContainer container) {
final Object key = container.createKey();
if (key != null) {
byKeyIndex.remove(key);
}
final Class<? extends NetworkNodeContainer> clazz = container.getClass();
deleteFromIndex(clazz, container);
removeFromIndex(clazz, container);
for (final Class<?> iface : clazz.getInterfaces()) {
deleteFromIndex(iface, container);
removeFromIndex(iface, container);
}
}

private void deleteFromIndex(final Class<?> indexKey, final NetworkNodeContainer container) {
final Set<? extends NetworkNodeContainer> index = containerIndex.get(indexKey);
private void removeFromIndex(final Class<?> indexKey, final NetworkNodeContainer container) {
final Set<? extends NetworkNodeContainer> index = byClassIndex.get(indexKey);
if (index != null) {
index.remove(container);
if (index.isEmpty()) {
containerIndex.remove(indexKey);
byClassIndex.remove(indexKey);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import javax.annotation.Nullable;

import org.junit.jupiter.api.BeforeEach;

import static java.util.Objects.requireNonNull;

abstract class AbstractNetworkBuilderImplTest {
protected NetworkBuilder sut;
private ComponentMapFactory<NetworkComponent, Network> componentMapFactory;
Expand All @@ -30,10 +32,8 @@ void setUp() {
sut = new NetworkBuilderImpl(new NetworkFactory(componentMapFactory));
}

protected void clearTracking(final Network network) {
Objects.requireNonNull(network)
.getComponent(InterceptingNetworkComponent.class)
.clear();
protected void clearTracking(@Nullable final Network network) {
requireNonNull(network).getComponent(InterceptingNetworkComponent.class).clear();
}

protected NetworkNodeContainer createContainerWithNetwork() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage2.api.network.impl;

import com.refinedmods.refinedstorage2.api.network.Network;
import com.refinedmods.refinedstorage2.api.network.impl.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.node.container.NetworkNodeContainer;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -50,7 +50,8 @@ void shouldFormNetwork() {
assertThat(unrelatedContainer.getNode().getNetwork())
.isNotNull()
.isNotEqualTo(container.getNode().getNetwork());
assertThat(unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
assertThat(
unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
.containsExactly(unrelatedContainer);
}

Expand Down Expand Up @@ -85,7 +86,8 @@ void shouldJoinExistingNetwork() {
assertThat(existingContainer1.getNode().getNetwork()).isEqualTo(expectedNetwork);
assertThat(existingContainer2.getNode().getNetwork()).isEqualTo(expectedNetwork);
assertThat(newContainer.getNode().getNetwork()).isEqualTo(expectedNetwork);
assertThat(expectedNetwork.getComponent(GraphNetworkComponent.class).getContainers()).containsExactlyInAnyOrder(
assertThat(
expectedNetwork.getComponent(GraphNetworkComponent.class).getContainers()).containsExactlyInAnyOrder(
existingContainer1,
existingContainer2,
newContainer
Expand All @@ -101,7 +103,8 @@ void shouldJoinExistingNetwork() {
assertThat(getNetworkMerges(expectedNetwork)).isEmpty();

assertThat(unrelatedContainer.getNode().getNetwork()).isNotNull().isNotEqualTo(expectedNetwork);
assertThat(unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
assertThat(
unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
.containsExactly(unrelatedContainer);
}

Expand Down Expand Up @@ -140,7 +143,8 @@ void shouldMergeWithExistingNetworks() {
assertThat(existingContainer2.getNode().getNetwork()).isEqualTo(expectedNetwork);
assertThat(existingContainer0.getNode().getNetwork()).isEqualTo(expectedNetwork);
assertThat(newContainer.getNode().getNetwork()).isEqualTo(expectedNetwork);
assertThat(expectedNetwork.getComponent(GraphNetworkComponent.class).getContainers()).containsExactlyInAnyOrder(
assertThat(
expectedNetwork.getComponent(GraphNetworkComponent.class).getContainers()).containsExactlyInAnyOrder(
existingContainer1,
existingContainer2,
existingContainer0,
Expand All @@ -154,7 +158,8 @@ void shouldMergeWithExistingNetworks() {
assertThat(getNetworkMerges(expectedNetwork)).isEmpty();

assertThat(unrelatedContainer.getNode().getNetwork()).isNotNull().isNotEqualTo(expectedNetwork);
assertThat(unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
assertThat(
unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
.containsExactly(unrelatedContainer);
}

Expand Down Expand Up @@ -190,7 +195,8 @@ void shouldFormNetworkIfThereAreNeighborsWithoutNetwork() {
assertThat(container2.getNode().getNetwork()).isEqualTo(expectedNetwork);
assertThat(container3.getNode().getNetwork()).isEqualTo(expectedNetwork);

assertThat(expectedNetwork.getComponent(GraphNetworkComponent.class).getContainers()).containsExactlyInAnyOrder(
assertThat(
expectedNetwork.getComponent(GraphNetworkComponent.class).getContainers()).containsExactlyInAnyOrder(
container1,
container2,
container3
Expand All @@ -202,7 +208,8 @@ void shouldFormNetworkIfThereAreNeighborsWithoutNetwork() {
assertThat(getAmountRemoved(expectedNetwork)).isZero();

assertThat(unrelatedContainer.getNode().getNetwork()).isNotNull().isNotEqualTo(expectedNetwork);
assertThat(unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
assertThat(
unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
.containsExactly(unrelatedContainer);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage2.api.network.impl;

import com.refinedmods.refinedstorage2.api.network.Network;
import com.refinedmods.refinedstorage2.api.network.impl.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.node.container.NetworkNodeContainer;

import java.util.List;
Expand Down Expand Up @@ -235,7 +235,8 @@ void shouldRemoveNetwork() {
assertThat(container.getNode().getNetwork()).isNull();

assertThat(unrelatedContainer.getNode().getNetwork()).isNotNull();
assertThat(unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
assertThat(
unrelatedContainer.getNode().getNetwork().getComponent(GraphNetworkComponent.class).getContainers())
.containsExactlyInAnyOrder(unrelatedContainer);

assertThat(network).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage2.api.network.impl;

import com.refinedmods.refinedstorage2.api.network.Network;
import com.refinedmods.refinedstorage2.api.network.impl.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.component.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.node.container.NetworkNodeContainer;

import java.util.Set;
Expand Down
Loading
Loading