Monday, December 23, 2013

MVC API Controller Error

You may get this very weird error when you test the API Controller using the Entity FX code-first approach. Here is my error,

Type 'System.Data.Entity.DynamicProxies.Speaker_78C9094BC0D38F33C0C4EEAD409D4FABB88C631E3F9CDA236EF6BE10DD027500' with data contract name 'Speaker_78C9094BC0D38F33C0C4EEAD409D4FABB88C631E3F9CDA236EF6BE10DD027500:http://schemas.datacontract.org/2004/07/System.Data.Entity.DynamicProxies' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.


and the Stacktrace,
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) at WriteArrayOfSpeakerToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract ) at System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter writer, Object graph) at System.Net.Http.Formatting.XmlMediaTypeFormatter.<>c__DisplayClass7.<WriteToStreamAsync>b__6() at System.Threading.Tasks.TaskHelpers.RunSynchronously(Action action, CancellationToken token)


and My code,

image

image

to Fix this, just turn off the proxycreation for this DBContext

image

Thursday, December 19, 2013

How to remove the dead nodes in the Solrcloud manually

Somehow, you may find SolrCloud has a track of all the Nodes even those dead or testing Nodes in the clustermap.

  for example, there is one dead nodes, here
image

If you hover on it, it shows the ip and port.
image

so here we go, remove the 8983 one. Basically the cluster state is keeped in the Zookeeper, all we need to do is download the file and remove the dead/testing nodes, then upload it back. To do this, we need download a full version of the zookeeper , under the bin ,the is a full featured zk client zkCli which enable us to get and set the data.

So save the clusterstate.json to local file.
image

find the dead ndoes, and remove it then save as a new file like new.txt
image

then upload it back,

./zkCli.sh -server 127.0.0.1:9984 set /clusterstate.json "`cat new.txt`"

then it’s gone!~

image

 
Locations of visitors to this page