001package com.pingidentity.sync.destination;
002
003import com.unboundid.directory.sdk.sync.api.SyncDestination;
004import com.unboundid.directory.sdk.sync.types.SyncOperation;
005import com.unboundid.ldap.sdk.Entry;
006import com.unboundid.ldap.sdk.Modification;
007
008import java.util.ArrayList;
009import java.util.List;
010
011/**
012 * This extension is useful when investigating performance
013 * with Sync. It will actually not do anything
014 * and return as quickly as possible to the sync core
015 * to help find bottlenecks and rule out the performance
016 * of the destination system.
017 * <p>
018 * It may also be used to terminate sync pipe in which custom processing is
019 * done as part of a plugin but no actual synchronization is required
020 */
021public class DevNull extends SyncDestination
022{
023    
024    @Override
025    public String getExtensionName()
026    {
027        return "DevNull Sync Destination";
028    }
029    
030    @Override
031    public String[] getExtensionDescription()
032    {
033        return new String[]{"A sync destination that is as fast as it gets. "
034                + "Use this sync destination if you need to test performance of a sync pipe, "
035                + "a sync instance or a sync source that you suspect is a bottleneck in a"
036                + "deployment. This sync destination is stripped of almost all processing"
037                + " so as to be a less likely contention point in a test."};
038    }
039    
040    /**
041     * Performs the necessary processing to compute the end point URL of this instance of the extension
042     *
043     * @return
044     */
045    @Override
046    public String getCurrentEndpointURL()
047    {
048        return "/dev/null";
049    }
050    
051    /**
052     * Performs no processing whatsoever
053     * That's precisely the point
054     *
055     * @param entryToCreate the entry to create
056     * @param operation     the sync operation
057     */
058    @Override
059    public void createEntry(Entry entryToCreate, SyncOperation operation)
060    {
061    }
062    
063    /**
064     * Performs no processing whatsoever
065     * That's precisely the point
066     *
067     * @param entryToModify the entry to modify
068     * @param modsToApply   the list of modifications to apply to the entry at the destination
069     * @param operation     the sync operation
070     */
071    @Override
072    public void modifyEntry(Entry entryToModify, List<Modification> modsToApply, SyncOperation operation)
073    {
074    }
075    
076    
077    /**
078     * Performs no processing whatsoever
079     * That's precisely the point
080     *
081     * @param entryToDelete the entry to delete
082     * @param operation     the sync operation
083     */
084    @Override
085    public void deleteEntry(Entry entryToDelete, SyncOperation operation)
086    {
087    }
088    
089    /**
090     * Returns the destination entry
091     *
092     * @param destEntryMappedFromSrc the destination entry to fetch
093     * @param operation              the sync operation
094     * @return a list of matching entries at the destination
095     */
096    public List<Entry> fetchEntry(Entry destEntryMappedFromSrc, SyncOperation operation)
097    {
098        List<Entry> result = new ArrayList<>(1);
099        result.add(destEntryMappedFromSrc);
100        return result;
101    }
102}