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

SpiNNakerManchester / JavaSpiNNaker / 14374629293

21 Mar 2025 04:17PM UTC coverage: 38.266% (-0.3%) from 38.579%
14374629293

push

github

web-flow
Merge pull request #1222 from SpiNNakerManchester/more_spalloc_rest_calls

More spalloc rest calls

70 of 815 new or added lines in 33 files covered. (8.59%)

29 existing lines in 13 files now uncovered.

9193 of 24024 relevant lines covered (38.27%)

1.14 hits per line

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

70.37
/SpiNNaker-front-end/src/main/java/uk/ac/manchester/spinnaker/front_end/BoardLocalSupport.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.front_end;
17

18
import static java.util.stream.Collectors.toList;
19
import static uk.ac.manchester.spinnaker.alloc.client.SpallocClientFactory.getJobFromProxyInfo;
20
import static uk.ac.manchester.spinnaker.messages.Constants.SCP_SCAMP_PORT;
21

22
import java.io.IOException;
23
import java.util.List;
24

25
import org.slf4j.MDC;
26
import org.slf4j.MDC.MDCCloseable;
27

28
import com.google.errorprone.annotations.MustBeClosed;
29

30
import uk.ac.manchester.spinnaker.alloc.client.SpallocClient;
31
import uk.ac.manchester.spinnaker.connections.MachineAware;
32
import uk.ac.manchester.spinnaker.machine.HasChipLocation;
33
import uk.ac.manchester.spinnaker.machine.Machine;
34
import uk.ac.manchester.spinnaker.storage.ProxyAwareStorage;
35
import uk.ac.manchester.spinnaker.storage.StorageException;
36
import uk.ac.manchester.spinnaker.transceiver.SpinnmanException;
37
import uk.ac.manchester.spinnaker.transceiver.Transceiver;
38
import uk.ac.manchester.spinnaker.transceiver.TransceiverInterface;
39
import uk.ac.manchester.spinnaker.transceiver.Transceiver.ConnectionDescriptor;
40

41
/**
42
 * A class for making things easier to do on a per-board basis.
43
 *
44
 * @author Donal Fellows
45
 */
46
public abstract class BoardLocalSupport {
47
        private static final String BOARD_ROOT = "boardRoot";
48

49
        /** A storage object that is aware of proxies. */
50
        protected final ProxyAwareStorage storage;
51

52
        /** The description of the SpiNNaker machine. */
53
        protected final Machine machine;
54

55
        /**
56
         * @param storage
57
         *            Database containing information about how to speak to the
58
         *            proxy.
59
         * @param machine
60
         *            Which machine is this on? Used for address mapping and
61
         *            provided as a general service to subclasses.
62
         */
63
        protected BoardLocalSupport(ProxyAwareStorage storage, Machine machine) {
3✔
64
                this.storage = storage;
3✔
65
                this.machine = machine;
3✔
66
        }
3✔
67

68
        private String root(HasChipLocation chipLoc) {
69
                var root = machine.getChipAt(chipLoc).nearestEthernet;
×
70
                return "(board:" + root.getX() + "," + root.getY() + ")";
×
71
        }
72

73
        @MustBeClosed
74
        @SuppressWarnings("MustBeClosed")
75
        protected TransceiverInterface getTransceiver()
76
                        throws IOException, StorageException, SpinnmanException,
77
                        InterruptedException {
78
                final TransceiverInterface txrx;
79
                var job = getJob();
3✔
80
                if (job == null) {
3✔
81
                        // No job; must be a direct connection
82
                        txrx = Transceiver.makeWithDescriptors(
3✔
83
                                        machine.version, generateScampConnections());
3✔
84
                } else {
NEW
85
                        txrx = job.getTransceiver();
×
86
                }
87
                var scpSelector = txrx.getScampConnectionSelector();
3✔
88
                if (scpSelector instanceof MachineAware) {
3✔
89
                        ((MachineAware) scpSelector).setMachine(machine);
3✔
90
                }
91
                return txrx;
3✔
92
        }
93

94
        private List<ConnectionDescriptor> generateScampConnections() {
95
                return machine.ethernetConnectedChips().stream()
3✔
96
                                .map(chip -> new ConnectionDescriptor(chip.ipAddress,
3✔
97
                                                SCP_SCAMP_PORT, chip.asChipLocation()))
3✔
98
                                .collect(toList());
3✔
99
        }
100

101
        protected SpallocClient.Job getJob() throws IOException, StorageException {
102
                if (storage == null) {
3✔
103
                        return null;
3✔
104
                }
105
                return getJobFromProxyInfo(storage.getProxyInformation());
3✔
106
        }
107

108
        /**
109
         * A context that can be pushed to state in logging what board is the root.
110
         *
111
         * @author Donal Fellows
112
         */
113
        protected final class BoardLocal implements AutoCloseable {
114
                private MDCCloseable context;
115

116
                /**
117
                 * @param chipLocation
118
                 *            The location of a chip on its board.
119
                 */
120
                public BoardLocal(HasChipLocation chipLocation) {
×
121
                        context = MDC.putCloseable(BOARD_ROOT, root(chipLocation));
×
122
                }
×
123

124
                @Override
125
                public void close() {
126
                        context.close();
×
127
                }
×
128
        }
129
}
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