让客户面对网络服务,今天早上开始抛出一个非常奇怪的例外.
Thread was being aborted.
at System.Net.UnsafeNclNativeMethods.OSSOCK.recv(IntPtr socketHandle, Byte* pinnedBuffer, Int32 len, SocketFlags socketFlags)
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
at System.Net.HttpWebRequest.EndWriteHeaders(Boolean async)
at System.Net.HttpWebRequest.WriteHeadersCallback(WebExceptionStatus errorStatus, ConnectStream stream, Boolean async)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
at System.Net.HttpWebRequest.EndSubmitRequest()
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.Web.Services2.SoapWebResponse..ctor(SoapWebRequest soapRequest)
at Microsoft.Web.Services2.SoapWebRequest.GetResponse()
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at Microsoft.Web.Services2.WebServicesClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一组 FTP Web 请求以下载一组文件。
在单个线程中正确执行此操作,但现在正在尝试使用多个线程,但出现超时异常。我想我错过了一些非常简单但似乎无法解决的问题
这是代码:
internal static void DownloadLogFiles(IEnumerable<string> ftpFileNames, string localLogsFolder)
{
BotFinder.DeleteAllFilesFromDirectory(localLogsFolder);
var ftpWebRequests = new Collection<FtpWebRequest>();
// Create web request for each log filename
foreach (var ftpWebRequest in ftpFileNames.Select(filename => (FtpWebRequest) WebRequest.Create(filename)))
{
ftpWebRequest.Credentials = new NetworkCredential(BotFinderSettings.FtpUserId, BotFinderSettings.FtpPassword);
ftpWebRequest.KeepAlive = false;
ftpWebRequest.UseBinary = true;
ftpWebRequest.CachePolicy = NoCachePolicy;
ftpWebRequest.Method = WebRequestMethods.Ftp.DownloadFile;
ftpWebRequests.Add(ftpWebRequest);
}
var threadDoneEvents = new ManualResetEvent[ftpWebRequests.Count];
for (var x = 0; x < ftpWebRequests.Count; x++)
{
var ftpWebRequest = ftpWebRequests[x];
threadDoneEvents[x] = new ManualResetEvent(false);
var …Run Code Online (Sandbox Code Playgroud) 我为我的应用程序创建了一个自定义配置部分.由于某种原因,Visual Studio 2010没有拾取和我的自定义属性.对于所有"添加"键,我收到与此类似的警告:
Could not find schema information for the element 'urlFilterSection'
Run Code Online (Sandbox Code Playgroud)
配置文件:
<configSections>
<section name="urlFilterSection" type="BotFinderApp.Models.UrlFilterSection, BotFinder" />
</configSections>
<urlFilterSection>
<urlFilterCollection>
<add url="urlhere.com.au" numberOfIpsToExtract="10" />
<add url="urlhere.com.au" numberOfIpsToExtract="10" />
<add url="urlhere.com.au" numberOfIpsToExtract="10" />
<add url="urlhere.com.au" numberOfIpsToExtract="10" />
<add url="urlhere.com.au" numberOfIpsToExtract="10" />
<add url="urlhere.com.au" numberOfIpsToExtract="10" />
<add url="urlhere.com.au" numberOfIpsToExtract="10" />
<add url="urlhere.com.au" numberOfIpsToExtract="10" />
<add url="urlhere.com.au" numberOfIpsToExtract="10" />
</urlFilterCollection>
</urlFilterSection>
Run Code Online (Sandbox Code Playgroud)
UrlFilterSection:
namespace BotFinderApp.Models
{
public class UrlFilterSection : ConfigurationSection
{
public UrlFilterSection()
{
}
[ConfigurationProperty("urlFilterCollection", IsDefaultCollection = false)]
[ConfigurationCollection(typeof(UrlFilterCollection), AddItemName …Run Code Online (Sandbox Code Playgroud) 我正在处理LocalDateTime对象,并希望将它们存储为Long纳秒精度。
我尝试过在Instant表示之间进行转换,但到目前为止失败了。
例如:
localDateTime.toInstant(ZoneOffset.UTC).getNano
仅返回纳秒部分localDateTime- 有没有办法返回完整的纳秒值?
类似于toEpochSecond纳秒,但不是以秒为单位?
我创建了一个依赖于 SLF4J 的包,因此我使用 Logback 来实现 OSGI。这一切都捆绑起来并安装正常,但是当我开始捆绑时,出现以下异常:
org.osgi.framework.BundleException:无法解析 com.felix.test [20](R 20.0):缺少要求 [com.felix.test [20](R 20.0)] osgi.wiring.package;(osgi.wiring.package=groovy.lang) 未解决的需求:[[com.felix.test [20](R 20.0)] osgi.wiring.package; (osgi.wiring.package=groovy.lang)]
我可以看到我的清单文件中groovy.lang列出了Import-Package,我很确定问题是 Logback 已被嵌入,但它的引用都没有。
我用来创建捆绑包,这是配置:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Import-Package>
*
</Import-Package>
<Embed-Dependency>
*
</Embed-Dependency>
<Embed-Directory>
osgi-inf/libs
</Embed-Directory>
<Embed-Transitive>
true
</Embed-Transitive>
</instructions>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这是我的清单:
Manifest-Version: 1.0
Bnd-LastModified: 1436982944102
Build-Jdk: 1.8.0_45
Built-By: tim.clifford
Bundle-ClassPath: .,osgi-inf/libs/org.osgi.core-1.0.0.jar,osgi-inf/libs/
servlet-api-2.5.jar,osgi-inf/libs/org.apache.felix.scr.annotations-1.9.
6.jar,osgi-inf/libs/httpclient-osgi-4.5.jar,osgi-inf/libs/httpclient-4.
5.jar,osgi-inf/libs/httpcore-4.4.1.jar,osgi-inf/libs/commons-logging-1.
2.jar,osgi-inf/libs/commons-codec-1.9.jar,osgi-inf/libs/httpmime-4.5.ja
r,osgi-inf/libs/httpclient-cache-4.5.jar,osgi-inf/libs/fluent-hc-4.5.ja
r,osgi-inf/libs/ehcache-2.10.0.jar,osgi-inf/libs/slf4j-api-1.7.7.jar,os
gi-inf/libs/commons-lang3-3.4.jar,osgi-inf/libs/logback-classic-1.1.3.j
ar,osgi-inf/libs/logback-core-1.1.3.jar
Bundle-ManifestVersion: 2
Bundle-Name: com.felix.test
Bundle-SymbolicName: com.felix.test
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle …Run Code Online (Sandbox Code Playgroud) 我试图通过pg_dump在 Docker 容器中运行kubectl并将输出保存到我的本地机器。
这是我到目前为止所拥有的:
kubectl exec -it MY_POD_NAME -- pg_dump -h DB_HOST -U USER_NAME SCHEMA_NAME > backup.sql
然而,这目前只是挂起。我相当肯定这是由于--忽略了>
kubectl exec -it MY_POD_NAME -- pg_dump -h DB_HOST -U USER_NAME SCHEMA_NAME 按预期输出到控制台。
简单的问题,但我无法在MSDN上的任何地方找到答案...
寻找ASP.NET将用于的默认值:
MailMessage.BodyEncoding 和 MailMessage.SubjectEncoding
如果你没有在代码中设置它们?
谢谢
我将字典绑定到下拉列表.
比如说我在字典中有以下项目:
{"Test1", 123}, {"Test2", 321}
Run Code Online (Sandbox Code Playgroud)
我希望下拉文本采用以下格式:
Test1 - Count: 123
Test2 - Count: 321
Run Code Online (Sandbox Code Playgroud)
我没有运气,沿着以下道路前进:
MyDropDown.DataTextFormatString = string.Format("{0} - Count: {1}", Key, Value);
Run Code Online (Sandbox Code Playgroud)
谢谢 :)
使用C#绑定到MVC3中的视图模型.
设置文本框的初始值有困难,尝试这样做而无需创建模板等
任何想法或我是否必须走创建自定义模板的道路?
蒂姆,谢谢
我是OSGI的新手(对不起)并且在尝试部署我的包和相关依赖项时遇到了一些问题.
这是我的POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.felix.test</groupId>
<artifactId>com.felix.test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.9.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
com.felix.test.search
</Export-Package>
<Bundle-SymbolicName>
${project.artifactId}
</Bundle-SymbolicName>
<Bundle-Activator>
com.felix.test.Activator
</Bundle-Activator>
</instructions>
</configuration>
</plugin> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Filebeat 将我的 K8s pod 日志发送到 Elasticsearch。
我在这里在线遵循指南:https : //www.elastic.co/guide/en/beats/filebeat/6.0/running-on-kubernetes.html
一切都按预期工作,但是我想从系统 pod 中过滤掉事件。我更新的配置看起来像:
apiVersion: v1
kind: ConfigMap
metadata:
name: filebeat-prospectors
namespace: kube-system
labels:
k8s-app: filebeat
kubernetes.io/cluster-service: "true"
data:
kubernetes.yml: |-
- type: log
paths:
- /var/lib/docker/containers/*/*.log
multiline.pattern: '^\s'
multiline.match: after
json.message_key: log
json.keys_under_root: true
processors:
- add_kubernetes_metadata:
in_cluster: true
namespace: ${POD_NAMESPACE}
- drop_event.when.regexp:
or:
kubernetes.pod.name: "weave-net.*"
kubernetes.pod.name: "external-dns.*"
kubernetes.pod.name: "nginx-ingress-controller.*"
kubernetes.pod.name: "filebeat.*"
Run Code Online (Sandbox Code Playgroud)
我试图忽视weave-net,external-dns,ingress-controller并filebeat通过事件:
- drop_event.when.regexp:
or:
kubernetes.pod.name: "weave-net.*"
kubernetes.pod.name: "external-dns.*"
kubernetes.pod.name: …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的文本文件解析应用程序,它搜索电子邮件地址,如果找到则添加到列表中.
目前列表中有重复的电子邮件地址,我正在寻找一种快速修改列表的方法,只包含不同的值 - 而不是逐个迭代它们:)
这是代码 -
var emailLines = new List<string>();
using (var stream = new StreamReader(@"C:\textFileName.txt"))
{
while (!stream.EndOfStream)
{
var currentLine = stream.ReadLine();
if (!string.IsNullOrEmpty(currentLine) && currentLine.StartsWith("Email: "))
{
emailLines.Add(currentLine);
}
}
}
Run Code Online (Sandbox Code Playgroud) c# ×7
asp.net ×4
java ×3
.net ×2
kubernetes ×2
osgi ×2
apache-felix ×1
app-config ×1
bash ×1
bndtools ×1
command-line ×1
date ×1
docker ×1
exception ×1
filebeat ×1
kibana ×1
logging ×1
mailmessage ×1
maven ×1
scala ×1
shell ×1
threadpool ×1
time ×1
web-services ×1