Skip to content
This repository was archived by the owner on May 10, 2018. It is now read-only.

Possible Fix for issue #34 #35

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open

Possible Fix for issue #34 #35

wants to merge 10 commits into from

Conversation

narkaTee
Copy link

Fixes Issue #34

@shakeelmohamed
Copy link
Contributor

Hi @narkaTee,

The changes look good, thank you again for doing this!
I apologize for the delay in responding, we've been busy the past few weeks preparing for .Conf last week.
If you resolve the merge conflicts, I'm happy to merge your changes.
Here are the git commands to resolve the conflict (it's just in the changelog):

  1. cd <repo location>
  2. git checkout bug/collectionlist2
  3. git remote add splunk git@github.com:splunk/splunk-sdk-php.git
  4. git cherry-pick 402f3a095e31c813d4370aa8cec86ef9a52c1767
  5. git push

@narkaTee
Copy link
Author

Hi @shakeelmohamed,

no problem I've been very busy too.
I just ran through the commands you suggested and pushed the result.

@shakeelmohamed
Copy link
Contributor

Hi @narkaTee,

It looks like there are more merge conflicts 😄. Please let us know if you need further guidance here

Please try the following, assuming you've already run step #1-3 from my previous comment:

  1. git fetch --all
  2. git merge splunk/develop
  3. You'll need to manually resolve the merge conflict - basically just remove the merge conflict formatting.

After running #2, you should see the following

index 6ed2483,87f7b56..0000000
--- a/Splunk/Job.php
+++ b/Splunk/Job.php
@@@ -33,7 -27,38 +33,42 @@@ class Splunk_Job extends Splunk_Entit
      const DEFAULT_FETCH_DELAY_PER_RETRY = 0.1;  // secs

      // === Load ===
++<<<<<<< HEAD
 + 
++=======
+     
+     /*
+      * Job requests sometimes yield an HTTP 204 code when they are in the
+      * process of being created. To hide this from the caller, transparently
+      * retry requests when an HTTP 204 is received.
+      */
+     protected function fetch($fetchArgs)
+     {
+         $fetchArgs = array_merge(array(
+             'maxTries' => Splunk_Job::DEFAULT_FETCH_MAX_TRIES,
+             'delayPerRetry' => Splunk_Job::DEFAULT_FETCH_DELAY_PER_RETRY,
+         ), $fetchArgs);
+         
+         for ($numTries = 0; $numTries < $fetchArgs['maxTries']; $numTries++)
+         {
+             $response = parent::fetch($fetchArgs);
+             if ($this->isFullResponse($response))
+                 return $response;
+             usleep($fetchArgs['delayPerRetry'] * 1000000);
+         }
+         
+         // If actually HTTP 200, convert to a simulated HTTP 204 response
+         if ($response->status != 204)
+         {
+             $response->status = 204;
+             $response->reason = "Timed out waiting for job to parse.";
+         }
+         
+         // Give up
+         throw new Splunk_HttpException($response);
+     }
+     
++>>>>>>> origin/develop
      protected function extractEntryFromRootXmlElement($xml)
      {
          // <entry> element is at the root of a job's Atom feed

To resolve the conflict, edit Splunk/Job.php - starting on line 36 to the following:

    /*
     * Job requests sometimes yield an HTTP 204 code when they are in the
     * process of being created. To hide this from the caller, transparently
     * retry requests when an HTTP 204 is received.
     */
    protected function fetch($fetchArgs)
    {
        $fetchArgs = array_merge(array(
            'maxTries' => Splunk_Job::DEFAULT_FETCH_MAX_TRIES,
            'delayPerRetry' => Splunk_Job::DEFAULT_FETCH_DELAY_PER_RETRY,
        ), $fetchArgs);

        for ($numTries = 0; $numTries < $fetchArgs['maxTries']; $numTries++)
        {
            $response = parent::fetch($fetchArgs);
            if ($this->isFullResponse($response))
                return $response;
            usleep($fetchArgs['delayPerRetry'] * 1000000);
        }

        // If actually HTTP 200, convert to a simulated HTTP 204 response
        if ($response->status != 204)
        {
            $response->status = 204;
            $response->reason = "Timed out waiting for job to parse.";
        }

        // Give up
        throw new Splunk_HttpException($response);
    }

@narkaTee
Copy link
Author

Hi @shakeelmohamed

I finally had some spare time to look at the conflict :)

I resolved it and stumbled upon a test which is obsolete after my changes.
Could you double check that JobTest::testGetTimeoutSimulated did only test the Splunk_Job::fetch method which I removed.

@shakeelmohamed shakeelmohamed self-assigned this Jun 14, 2016
@shakeelmohamed
Copy link
Contributor

Thanks @narkaTee!
We'll run the tests on a few combinations of Splunk & PHP before merging

@shakeelmohamed shakeelmohamed removed their assignment Aug 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants