コード例 #1
0
ファイル: athena.c プロジェクト: chris-wood/ghost
Athena *
athena_Create(size_t contentStoreSizeInMB)
{
    Athena *athena = parcObject_CreateAndClearInstance(Athena);

    athena->athenaName = ccnxName_CreateFromURI(CCNxNameAthena_Forwarder);
    assertNotNull(athena->athenaName, "Failed to create forwarder name (%s)", CCNxNameAthena_Forwarder);

    athena->athenaFIB = athenaFIB_Create();
    assertNotNull(athena->athenaFIB, "Failed to create FIB");

    athena->athenaPIT = athenaPIT_Create();
    assertNotNull(athena->athenaPIT, "Failed to create PIT");

    AthenaLRUContentStoreConfig storeConfig;
    storeConfig.capacityInMB = contentStoreSizeInMB;

    athena->athenaContentStore = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &storeConfig);
    assertNotNull(athena->athenaContentStore, "Failed to create Content Store");

    athena->athenaTransportLinkAdapter = athenaTransportLinkAdapter_Create(_removeLink, athena);
    assertNotNull(athena->athenaTransportLinkAdapter, "Failed to create Transport Link Adapter");

    athena->log = _athena_logger_create();
    athena->athenaState = Athena_Running;

    return athena;
}
コード例 #2
0
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);
}
コード例 #3
0
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);
}
コード例 #4
0
LONGBOW_TEST_CASE(Global, createRelease)
{
    AthenaLRUContentStoreConfig config;

    config.capacityInMB = 10;

    AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config);

    athenaContentStore_Release(&store);
}
コード例 #5
0
LONGBOW_TEST_CASE(EmptyImplementation, apiFunctions)
{
    AthenaContentStore *store = athenaContentStore_Create(&EmptyContentStoreImplementation, NULL);
    CCNxName *name = ccnxName_CreateFromURI("lci:/pie/is/always/good");
    CCNxInterest *interest = ccnxInterest_CreateSimple(name);

    athena_EncodeMessage(interest);

    assertNull(athenaContentStore_ProcessMessage(store, interest), "Expected a NULL response.");

    ccnxName_Release(&name);
    ccnxInterest_Release(&interest);
    athenaContentStore_Release(&store);
}
コード例 #6
0
LONGBOW_TEST_CASE(Global, setGetCapacity)
{
    AthenaLRUContentStoreConfig config;
    config.capacityInMB = 10;
    AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config);

    size_t capacity = athenaContentStore_GetCapacity(store);
    assertTrue(capacity = config.capacityInMB, "Expected the same capacity as we specified at init");

    size_t newCapacity = 20;
    athenaContentStore_SetCapacity(store, newCapacity);

    assertTrue(newCapacity == athenaContentStore_GetCapacity(store), "Expected to see the new capacity");

    athenaContentStore_Release(&store);
}
コード例 #7
0
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);
}
コード例 #8
0
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);
}
コード例 #9
0
LONGBOW_TEST_CASE(Global, processMessage)
{
    AthenaLRUContentStoreConfig config;
    config.capacityInMB = 10;
    AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config);

    CCNxName *name = ccnxName_CreateFromURI(CCNxNameAthena_ContentStore "/stat/size");
    CCNxInterest *interest = ccnxInterest_CreateSimple(name);

    CCNxMetaMessage *message = ccnxMetaMessage_CreateFromInterest(interest);

    athena_EncodeMessage(message);

    CCNxMetaMessage *result = athenaContentStore_ProcessMessage(store, message);

    assertNotNull(result, "Expected a response from the store");

    ccnxMetaMessage_Release(&result);
    ccnxMetaMessage_Release(&message);
    ccnxInterest_Release(&interest);
    ccnxName_Release(&name);

    athenaContentStore_Release(&store);
}
コード例 #10
0
static AthenaContentStore *
_emptyImplSetup()
{
    return athenaContentStore_Create(&EmptyContentStoreImplementation, NULL);
}