static void _processContentObject(Athena *athena, CCNxContentObject *contentObject, PARCBitVector *ingressVector) { // // * (1) If it does not match anything in the PIT, drop it // PARCBitVector *egressVector = athenaPIT_Match(athena->athenaPIT, contentObject, ingressVector); if (egressVector) { if (parcBitVector_NumberOfBitsSet(egressVector) > 0) { // // * (2) Add to the Content Store // athenaContentStore_PutContentObject(athena->athenaContentStore, contentObject); // // * (3) Reverse path forward it via PIT entries // const char *egressVectorString = parcBitVector_ToString(egressVector); parcLog_Debug(athena->log, "Content Object forwarded to %s.", egressVectorString); parcMemory_Deallocate(&egressVectorString); PARCBitVector *result = athenaTransportLinkAdapter_Send(athena->athenaTransportLinkAdapter, contentObject, egressVector); if (result) { // if there are failed channels, client will resend interest unless we wish to retry here parcBitVector_Release(&result); } } parcBitVector_Release(&egressVector); } }
LONGBOW_TEST_CASE(Global, removeMatch) { AthenaLRUContentStoreConfig config; config.capacityInMB = 10; AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config); PARCClock *clock = parcClock_Wallclock(); char *lci = "lci:/cakes/and/pies"; CCNxName *origName = ccnxName_CreateFromURI(lci); CCNxContentObject *contentObject = ccnxContentObject_CreateWithDataPayload(origName, NULL); ccnxContentObject_SetExpiryTime(contentObject, parcClock_GetTime(clock) + 100); ccnxName_Release(&origName); athenaContentStore_PutContentObject(store, contentObject); ccnxContentObject_Release(&contentObject); CCNxName *testName = ccnxName_CreateFromURI(lci); bool status = athenaContentStore_RemoveMatch(store, testName, NULL, NULL); // TODO: match on other than name! assertTrue(status, "Expected to remove the contentobject we had"); ccnxName_Release(&testName); parcClock_Release(&clock); athenaContentStore_Release(&store); }
LONGBOW_TEST_CASE(Global, getMatchByName) { AthenaLRUContentStoreConfig config; config.capacityInMB = 10; AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config); char *lci = "lci:/cakes/and/pies"; PARCClock *clock = parcClock_Wallclock(); CCNxName *truthName = ccnxName_CreateFromURI(lci); CCNxContentObject *truthObject = ccnxContentObject_CreateWithDataPayload(truthName, NULL); ccnxContentObject_SetExpiryTime(truthObject, parcClock_GetTime(clock) + 100); ccnxName_Release(&truthName); athenaContentStore_PutContentObject(store, truthObject); CCNxName *testName = ccnxName_CreateFromURI(lci); CCNxInterest *interest = ccnxInterest_CreateSimple(testName); ccnxName_Release(&testName); //athena_EncodeMessage(interest); CCNxContentObject *testObject = athenaContentStore_GetMatch(store, interest); ccnxInterest_Release(&interest); // TODO: match on other than name! assertTrue(ccnxContentObject_Equals(truthObject, testObject), "Expected to get the same ContentObject back"); assertTrue(truthObject == testObject, "Expected the same pointer back"); athenaContentStore_Release(&store); ccnxContentObject_Release(&truthObject); parcClock_Release(&clock); }
LONGBOW_TEST_CASE(Global, putContent) { AthenaLRUContentStoreConfig config; config.capacityInMB = 10; AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config); PARCBuffer *payload = parcBuffer_WrapCString("this is a payload"); CCNxContentObject *contentObject = _createContentObject("lci:/cakes/and/pies", 0, payload); parcBuffer_Release(&payload); ccnxContentObject_SetExpiryTime(contentObject, 100); athenaContentStore_PutContentObject(store, contentObject); athenaContentStore_Release(&store); ccnxContentObject_Release(&contentObject); }
LONGBOW_TEST_CASE(EmptyImplementation, booleanApiFunctions) { AthenaContentStore *store = athenaContentStore_Create(&EmptyContentStoreImplementation, NULL); CCNxContentObject *contentObject = _createContentObject("lci:/dogs/are/better/than/cats", 10, NULL); CCNxName *name = ccnxName_CreateFromURI("lci:/pie/is/always/good"); CCNxInterest *interest = ccnxInterest_CreateSimple(name); //athena_EncodeMessage(interest); AthenaContentStore *ref = athenaContentStore_Acquire(store); athenaContentStore_Release(&ref); assertFalse(athenaContentStore_PutContentObject(store, contentObject), "Expected false from PutContentObject"); assertFalse(athenaContentStore_GetMatch(store, interest), "Expected false from GetMatch"); assertFalse(athenaContentStore_SetCapacity(store, 1), "Expected false from SetCapacity"); assertFalse(athenaContentStore_RemoveMatch(store, name, NULL, NULL), "Expected false from RemoveMatch"); ccnxName_Release(&name); ccnxInterest_Release(&interest); ccnxContentObject_Release(&contentObject); athenaContentStore_Release(&store); }