public boolean receivedAllChunks() { long nOfChunks = numberOfChunks.getValue(); for (int i = 0; i < nOfChunks; i++) { if (receivedChunks.get(i) == null) { return false; } } return true; }
protected TCPIPFixedBinaryListDecoder(List list, final BufferHolder srcBuffer, final BinaryTimeHandler timeHandler) throws MALException { super(srcBuffer, timeHandler); this.list = list; // decode number of elements in list this.size = (int) decodeUInteger().getValue(); }
@Override public void retrieveRangeAgainUpdateReceived(org.ccsds.moims.mo.mal.transport.MALMessageHeader msgHeader, org.ccsds.moims.mo.mal.structures.Blob chunk, org.ccsds.moims.mo.mal.structures.UInteger indexReceived, java.util.Map qosProperties) { int index = (int) indexReceived.getValue(); Logger.getLogger(ArchiveSyncGenAdapter.class.getName()).log(Level.INFO, "Received on rerequest! Chunk index: " + index); lastTimeReceived = System.currentTimeMillis(); try { receivedChunks.add(index, chunk.getValue()); } catch (MALException ex) { Logger.getLogger(ArchiveSyncGenAdapter.class.getName()).log(Level.SEVERE, null, ex); } }
@Override public synchronized void retrieveRangeUpdateReceived(org.ccsds.moims.mo.mal.transport.MALMessageHeader msgHeader, Blob chunk, UInteger indexReceived, java.util.Map qosProperties) { int index = (int) indexReceived.getValue(); /* Logger.getLogger(ArchiveSyncAdapter.class.getName()).log(Level.INFO, "Received! Chunk index: " + index); */ lastTimeReceived = System.currentTimeMillis(); lastknowIndex = index; try { receivedChunks.add(index, chunk.getValue()); } catch (MALException ex) { Logger.getLogger(ArchiveSyncGenAdapter.class.getName()).log(Level.SEVERE, null, ex); } }
/** * converts a validityState to its UOctet-Value * * @param valState the validityState to be converted * @return the converted validityState as an UOctet */ private UOctet getAsUOctet(ValidityState valState) { return new UOctet((short) valState.getNumericValue().getValue()); }
/** * Encode an unsigned integer using split-binary encoding for a 4-byte * variable sized int */ @Override public void encodeUInteger(final UInteger value) throws MALException { try { ((TCPIPStreamHolder) outputStream).addUnsignedVarint4((int) value.getValue()); } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
public UIntegerList getMissingIndexes() { UIntegerList missingIndexes = new UIntegerList(); long nOfChunks = numberOfChunks.getValue(); for (int i = 0; i < nOfChunks; i++) { if (receivedChunks.get(i) == null) { missingIndexes.add(new UInteger()); } } return missingIndexes; }
@Override public void run() { try { archiveService.store( false, ActivityTrackingHelper.OPERATIONACTIVITY_OBJECT_TYPE, interaction.getMessageHeader().getDomain(), archiveDetails, opActivityList, interaction); // requirement: 3.5.2.3 & 3.5.2.5 } catch (MALException ex) { Logger.getLogger(ActivityTrackingProviderServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } catch (MALInteractionException ex) { // A duplicate might happen if the the consumer stored the Operation Activity object if(ex.getStandardError().getErrorNumber().getValue() != COMHelper.DUPLICATE_ERROR_NUMBER.getValue()){ Logger.getLogger(ActivityTrackingProviderServiceImpl.class.getName()).log(Level.SEVERE, null, ex); }else{ // It's a Duplicate error, the object already exists... Do nothing! } } } });
@Override public Blob decodeBlob() throws MALException { int sz = (int) decodeUInteger().getValue(); if (sz == 0) { return null; } return new Blob(sourceBuffer.directGetBytes(sz)); }
@Override public void encodeUInteger(final UInteger value) throws MALException { try { checkForNull(value); outputStream.addUnsignedLong32(value.getValue()); } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
@Override public void encodeUInteger(final UInteger value) throws MALException { try { checkForNull(value); outputStream.addUnsignedLong32(value.getValue()); } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
@Override public void retrieveRangeAgain(final Long transactionTicket, final UIntegerList missingIndexes, final RetrieveRangeAgainInteraction interaction) throws MALInteractionException, MALException { final Dispatcher dispatcher = dispatchers.get(transactionTicket); if (dispatcher == null) { throw new MALInteractionException(new MALStandardError(COMHelper.INVALID_ERROR_NUMBER, null)); } interaction.sendAcknowledgement(); if (missingIndexes.size() == 2 && missingIndexes.get(1).getValue() == 0) { // Special case! The condition means that we need to retransmit // everything since the value in missingIndexes.get(0) UInteger lastIndex = missingIndexes.get(0); try { int numberOfChunks = dispatcher.numberOfChunks(); for (int i = (int) lastIndex.getValue(); i < numberOfChunks; i++) { byte[] chunk = dispatcher.getFlushedChunk(i); interaction.sendUpdate(new Blob(chunk), new UInteger(i)); } } catch (IOException ex) { Logger.getLogger(ArchiveSyncProviderServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } } else { for (UInteger missingIndex : missingIndexes) { byte[] chunk = dispatcher.getFlushedChunk((short) missingIndex.getValue()); interaction.sendUpdate(new Blob(chunk), missingIndex); } } interaction.sendResponse(); }
return (double) ((UInteger) in).getValue();
public static double getDouble(Attribute attr) { int type = attr.getTypeShortForm(); switch (type) { case Attribute._DOUBLE_TYPE_SHORT_FORM: //Already double. return ((Union) attr).getDoubleValue(); case Attribute._SHORT_TYPE_SHORT_FORM: // Short. return ((Union) attr).getShortValue(); case Attribute._USHORT_TYPE_SHORT_FORM: // UShort return ((UShort) attr).getValue(); case Attribute._INTEGER_TYPE_SHORT_FORM: // Integer return ((Union) attr).getIntegerValue(); case Attribute._UINTEGER_TYPE_SHORT_FORM: // UInteger return ((UInteger) attr).getValue(); case Attribute._LONG_TYPE_SHORT_FORM: // Long return ((Union) attr).getLongValue(); } return 0; }