• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / JavaSpiNNaker / 13520271443

25 Feb 2025 11:34AM UTC coverage: 38.48% (-0.03%) from 38.51%
13520271443

push

github

rowleya
Fix tabs

675 of 2950 new or added lines in 17 files covered. (22.88%)

9 existing lines in 2 files now uncovered.

9182 of 23862 relevant lines covered (38.48%)

1.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/SpiNNaker-comms/src/main/java/uk/ac/manchester/spinnaker/protocols/SystemRouterTableContext.java
1
/*
2
 * Copyright (c) 2019 The University of Manchester
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package uk.ac.manchester.spinnaker.protocols;
17

18
import static org.slf4j.LoggerFactory.getLogger;
19

20
import java.io.IOException;
21
import java.util.List;
22
import java.util.stream.Stream;
23

24
import org.slf4j.Logger;
25

26
import com.google.errorprone.annotations.MustBeClosed;
27

28
import uk.ac.manchester.spinnaker.machine.ChipLocation;
29
import uk.ac.manchester.spinnaker.machine.CoreSubsets;
30
import uk.ac.manchester.spinnaker.machine.HasCoreLocation;
31
import uk.ac.manchester.spinnaker.transceiver.ProcessException;
32
import uk.ac.manchester.spinnaker.transceiver.TransceiverInterface;
33

34
/**
35
 * A context class that loads up the system router tables while it is active.
36
 *
37
 * @author Donal Fellows
38
 */
39
public class SystemRouterTableContext implements AutoCloseable {
NEW
40
        private static final Logger log = getLogger(SystemRouterTableContext.class);
×
41

42
        private final CoreSubsets monitorCores;
43

44
        private final TransceiverInterface txrx;
45

46
        private final ChipLocation firstChip;
47

48
        /**
49
         * Create a no-drop-packets context.
50
         *
51
         * @param txrx
52
         *            The transceiver to use for talking to SpiNNaker.
53
         * @param monitorCores
54
         *            The extra monitor cores on the SpiNNaker system that control
55
         *            the routers.
56
         * @throws IOException
57
         *             If communications fail.
58
         * @throws ProcessException
59
         *             If SCAMP or an extra monitor rejects a message.
60
         * @throws InterruptedException
61
         *             If communications are interrupted.
62
         */
63
        @MustBeClosed
64
        public SystemRouterTableContext(TransceiverInterface txrx,
65
                        CoreSubsets monitorCores)
NEW
66
                        throws IOException, ProcessException, InterruptedException {
×
NEW
67
                this.txrx = txrx;
×
NEW
68
                this.monitorCores = monitorCores;
×
NEW
69
                var firstCore = monitorCores.first().orElseThrow();
×
NEW
70
                firstChip = firstCore.asChipLocation();
×
71

NEW
72
                log.info("switching multicast routing on board at {} to system mode",
×
73
                                firstChip);
NEW
74
                log.info("will switch {} cores", monitorCores.size());
×
75
                try {
NEW
76
                        txrx.saveApplicationRouterTables(monitorCores);
×
NEW
77
                        txrx.loadSystemRouterTables(monitorCores);
×
NEW
78
                } catch (IOException | ProcessException | InterruptedException e) {
×
NEW
79
                        log.error("failed to switch multicast routing on {} to system",
×
80
                                        firstChip, e);
NEW
81
                        throw e;
×
NEW
82
                }
×
NEW
83
        }
×
84

85
        /**
86
         * Create a no-drop-packets context.
87
         *
88
         * @param txrx
89
         *            The transceiver to use for talking to SpiNNaker.
90
         * @param monitorCoreLocations
91
         *            The extra monitor cores on the SpiNNaker system that control
92
         *            the routers.
93
         * @throws IOException
94
         *             If communications fail.
95
         * @throws ProcessException
96
         *             If SCAMP or an extra monitor rejects a message.
97
         * @throws InterruptedException
98
         *             If communications are interrupted.
99
         */
100
        @MustBeClosed
101
        public SystemRouterTableContext(TransceiverInterface txrx,
102
                        List<? extends HasCoreLocation> monitorCoreLocations)
103
                        throws IOException, ProcessException, InterruptedException {
NEW
104
                this(txrx, convertToCoreSubset(monitorCoreLocations));
×
NEW
105
        }
×
106

107
        /**
108
         * Create a no-drop-packets context.
109
         *
110
         * @param txrx
111
         *            The transceiver to use for talking to SpiNNaker.
112
         * @param monitorCoreLocations
113
         *            The extra monitor cores on the SpiNNaker system that control
114
         *            the routers.
115
         * @throws IOException
116
         *             If communications fail.
117
         * @throws ProcessException
118
         *             If SCAMP or an extra monitor rejects a message.
119
         * @throws InterruptedException
120
         *             If communications are interrupted.
121
         */
122
        @MustBeClosed
123
        public SystemRouterTableContext(TransceiverInterface txrx,
124
                        Stream<? extends HasCoreLocation> monitorCoreLocations)
125
                        throws IOException, ProcessException, InterruptedException {
NEW
126
                this(txrx, convertToCoreSubset(monitorCoreLocations));
×
NEW
127
        }
×
128

129
        private static CoreSubsets convertToCoreSubset(
130
                        List<? extends HasCoreLocation> coreLocationList) {
NEW
131
                var cores = new CoreSubsets();
×
NEW
132
                for (var coreLocation : coreLocationList) {
×
NEW
133
                        cores.addCore(coreLocation.asCoreLocation());
×
NEW
134
                }
×
NEW
135
                return cores;
×
136
        }
137

138
        private static CoreSubsets convertToCoreSubset(
139
                        Stream<? extends HasCoreLocation> coreLocations) {
NEW
140
                var cores = new CoreSubsets();
×
NEW
141
                coreLocations.forEach(loc -> cores.addCore(loc.asCoreLocation()));
×
NEW
142
                return cores;
×
143
        }
144

145
        /**
146
         * Restore the SpiNNaker board to its normal operating mode.
147
         *
148
         * @throws IOException
149
         *             If communications fail.
150
         * @throws ProcessException
151
         *             If SCAMP or an extra monitor rejects a message.
152
         * @throws InterruptedException
153
         *             If communications are interrupted.
154
         */
155
        @Override
156
        public void close()
157
                        throws IOException, ProcessException, InterruptedException {
NEW
158
                log.info("switching multicast routing on board at {} to standard mode",
×
159
                                firstChip);
160

161
                try {
NEW
162
                        txrx.loadApplicationRouterTables(monitorCores);
×
NEW
163
                } catch (IOException | ProcessException | InterruptedException e) {
×
NEW
164
                        log.error("error restoring multicast router tables", e);
×
NEW
165
                        throw e;
×
NEW
166
                }
×
NEW
167
        }
×
168
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc