Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
ee538faf
Commit
ee538faf
authored
Nov 25, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added profile and logging to connection
parent
1c08c06d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
Connection.php
extensions/elasticsearch/Connection.php
+15
-10
No files found.
extensions/elasticsearch/Connection.php
View file @
ee538faf
...
@@ -213,12 +213,7 @@ class Connection extends Component
...
@@ -213,12 +213,7 @@ class Connection extends Component
if
(
!
empty
(
$options
))
{
if
(
!
empty
(
$options
))
{
$url
.=
'?'
.
http_build_query
(
$options
);
$url
.=
'?'
.
http_build_query
(
$options
);
}
}
return
$url
;
$host
=
$this
->
nodes
[
$this
->
activeNode
][
'http_address'
];
if
(
strncmp
(
$host
,
'inet[/'
,
6
)
==
0
)
{
$host
=
substr
(
$host
,
6
,
-
1
);
}
return
'http://'
.
$host
.
'/'
.
$url
;
}
}
protected
function
httpRequest
(
$method
,
$url
,
$requestBody
=
null
)
protected
function
httpRequest
(
$method
,
$url
,
$requestBody
=
null
)
...
@@ -264,13 +259,23 @@ class Connection extends Component
...
@@ -264,13 +259,23 @@ class Connection extends Component
unset
(
$options
[
CURLOPT_WRITEFUNCTION
]);
unset
(
$options
[
CURLOPT_WRITEFUNCTION
]);
}
}
$curl
=
curl_init
(
$url
);
$host
=
$this
->
nodes
[
$this
->
activeNode
][
'http_address'
];
if
(
strncmp
(
$host
,
'inet[/'
,
6
)
==
0
)
{
$host
=
substr
(
$host
,
6
,
-
1
);
}
Yii
::
trace
(
"Sending request to elasticsearch node '
$host
'
$url
\n
$requestBody
"
,
__METHOD__
);
Yii
::
beginProfile
(
$url
.
$requestBody
,
__METHOD__
);
$curl
=
curl_init
(
'http://'
.
$host
.
'/'
.
$url
);
curl_setopt_array
(
$curl
,
$options
);
curl_setopt_array
(
$curl
,
$options
);
curl_exec
(
$curl
);
curl_exec
(
$curl
);
$responseCode
=
curl_getinfo
(
$curl
,
CURLINFO_HTTP_CODE
);
$responseCode
=
curl_getinfo
(
$curl
,
CURLINFO_HTTP_CODE
);
curl_close
(
$curl
);
curl_close
(
$curl
);
Yii
::
endProfile
(
$url
.
$requestBody
,
__METHOD__
);
if
(
$responseCode
>=
200
&&
$responseCode
<
300
)
{
if
(
$responseCode
>=
200
&&
$responseCode
<
300
)
{
if
(
$method
==
'HEAD'
)
{
if
(
$method
==
'HEAD'
)
{
return
true
;
return
true
;
...
@@ -278,7 +283,7 @@ class Connection extends Component
...
@@ -278,7 +283,7 @@ class Connection extends Component
if
(
isset
(
$headers
[
'content-length'
])
&&
(
$len
=
mb_strlen
(
$body
,
'8bit'
))
<
$headers
[
'content-length'
])
{
if
(
isset
(
$headers
[
'content-length'
])
&&
(
$len
=
mb_strlen
(
$body
,
'8bit'
))
<
$headers
[
'content-length'
])
{
throw
new
Exception
(
"Incomplete data received from elasticsearch:
$len
<
{
$headers
[
'content-length'
]
}
"
,
[
throw
new
Exception
(
"Incomplete data received from elasticsearch:
$len
<
{
$headers
[
'content-length'
]
}
"
,
[
'requestMethod'
=>
$method
,
'requestMethod'
=>
$method
,
'requestUrl'
=>
$url
,
'requestUrl'
=>
'http://'
.
$host
.
'/'
.
$url
,
'requestBody'
=>
$requestBody
,
'requestBody'
=>
$requestBody
,
'responseCode'
=>
$responseCode
,
'responseCode'
=>
$responseCode
,
'responseHeaders'
=>
$headers
,
'responseHeaders'
=>
$headers
,
...
@@ -290,7 +295,7 @@ class Connection extends Component
...
@@ -290,7 +295,7 @@ class Connection extends Component
}
}
throw
new
Exception
(
'Unsupported data received from elasticsearch: '
.
$headers
[
'content-type'
],
[
throw
new
Exception
(
'Unsupported data received from elasticsearch: '
.
$headers
[
'content-type'
],
[
'requestMethod'
=>
$method
,
'requestMethod'
=>
$method
,
'requestUrl'
=>
$url
,
'requestUrl'
=>
'http://'
.
$host
.
'/'
.
$url
,
'requestBody'
=>
$requestBody
,
'requestBody'
=>
$requestBody
,
'responseCode'
=>
$responseCode
,
'responseCode'
=>
$responseCode
,
'responseHeaders'
=>
$headers
,
'responseHeaders'
=>
$headers
,
...
@@ -302,7 +307,7 @@ class Connection extends Component
...
@@ -302,7 +307,7 @@ class Connection extends Component
}
else
{
}
else
{
throw
new
Exception
(
"Elasticsearch request failed with code
$responseCode
."
,
[
throw
new
Exception
(
"Elasticsearch request failed with code
$responseCode
."
,
[
'requestMethod'
=>
$method
,
'requestMethod'
=>
$method
,
'requestUrl'
=>
$url
,
'requestUrl'
=>
'http://'
.
$host
.
'/'
.
$url
,
'requestBody'
=>
$requestBody
,
'requestBody'
=>
$requestBody
,
'responseCode'
=>
$responseCode
,
'responseCode'
=>
$responseCode
,
'responseHeaders'
=>
$headers
,
'responseHeaders'
=>
$headers
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment